mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
- 升级 actions/checkout 从 v4 到 v6 - 升级 pnpm/action-setup 从 v3 到 v4 并更新版本到 latest - 升级 actions/setup-node 从 v4 到 v6 - 升级 actions/setup-java 从 v4 到 v5 - 升级 actions/cache 从 v4 到 v5 - 升级 softprops/action-gh-release 从 v1 到 v2 - 升级 actions/configure-pages 从 v3 到 v5 - 升级 actions/deploy-pages 从 v2 到 v4 - 添加构建产物验证步骤 - 添加缓存 pnpm 依赖的配置 - 优化 Docker 镜像标签和元数据配置 - 改进条件判断逻辑以优化 Docker 推送流程
73 lines
1.7 KiB
YAML
73 lines
1.7 KiB
YAML
name: 构建 Github Pages
|
||
|
||
on:
|
||
push:
|
||
branches: [main] # 如果你的主分支叫 master,请改为 master
|
||
|
||
permissions:
|
||
contents: read
|
||
pages: write
|
||
id-token: write
|
||
|
||
jobs:
|
||
build-and-deploy:
|
||
runs-on: ubuntu-latest
|
||
environment:
|
||
name: github-pages
|
||
url: ${{ steps.deployment.outputs.page_url }}
|
||
steps:
|
||
- name: 检出代码
|
||
uses: actions/checkout@v6
|
||
|
||
- name: 设置 pnpm
|
||
uses: pnpm/action-setup@v4
|
||
with:
|
||
version: latest
|
||
|
||
- name: 设置 Node.js
|
||
uses: actions/setup-node@v6
|
||
with:
|
||
node-version: '20'
|
||
|
||
- name: 缓存 pnpm 依赖
|
||
uses: actions/cache@v5
|
||
with:
|
||
path: |
|
||
~/.pnpm-store
|
||
node_modules
|
||
key: ${{ runner.os }}-pnpm-pages-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-pnpm-pages-
|
||
|
||
- name: 安装依赖
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: 构建前端项目
|
||
run: pnpm run build
|
||
|
||
- name: 验证构建产物
|
||
run: |
|
||
if [ ! -d "docs" ]; then
|
||
echo "❌ 构建失败:docs 目录不存在"
|
||
exit 1
|
||
fi
|
||
if [ ! -f "docs/index.html" ]; then
|
||
echo "❌ 构建失败:docs/index.html 不存在"
|
||
exit 1
|
||
fi
|
||
echo "✅ 构建产物验证通过"
|
||
ls -la docs/
|
||
|
||
# 关键步骤:告诉 GitHub Actions 跳过 Jekyll 检查
|
||
- name: 配置 Github Pages
|
||
uses: actions/configure-pages@v5
|
||
|
||
- name: 上传构建版
|
||
uses: actions/upload-pages-artifact@v4
|
||
with:
|
||
path: './docs'
|
||
|
||
- name: 部署到 GitHub Pages
|
||
id: deployment
|
||
uses: actions/deploy-pages@v4
|