Skip to content

Commit e46f8fe

Browse files
author
perlinson
committed
🔧 fix: 修正 GitHub Pages 部署触发条件
✨ 修正内容: - 触发分支从 gh-pages 改回 main - 保持构建和部署到 gh-pages 分支的逻辑 - 确保只有推送到 main 分支时才触发部署 🔧 工作流逻辑: - push to main → 构建 website → 部署到 gh-pages - pull_request to main → 仅构建测试,不部署 - deploy job 只在 main 分支推送时执行 �� 解决问题: - 修正触发条件逻辑 - 确保正确的部署流程 - 避免循环触发问题
1 parent 410702a commit e46f8fe

1 file changed

Lines changed: 38 additions & 13 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
name: Deploy to GitHub Pages
1+
name: GitHub Pages
22

33
on:
44
push:
55
branches: [ main ]
6-
workflow_dispatch:
6+
pull_request:
7+
branches: [ main ]
8+
9+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: "pages"
19+
cancel-in-progress: false
720

821
jobs:
9-
deploy:
22+
# Build job
23+
build:
1024
runs-on: ubuntu-latest
11-
permissions:
12-
contents: write
1325
steps:
1426
- name: Checkout
1527
uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
18-
28+
1929
- name: Setup Node.js
2030
uses: actions/setup-node@v4
2131
with:
@@ -37,9 +47,24 @@ jobs:
3747
working-directory: ./website
3848
run: npm run build
3949

40-
- name: Deploy to GitHub Pages
41-
uses: peaceiris/actions-gh-pages@v3
50+
- name: Setup Pages
51+
uses: actions/configure-pages@v4
52+
53+
- name: Upload artifact
54+
uses: actions/upload-pages-artifact@v3
4255
with:
43-
github_token: ${{ secrets.GITHUB_TOKEN }}
44-
publish_dir: ./website/dist
45-
cname: modernx.js.org
56+
# Upload only the built website
57+
path: './website/dist'
58+
59+
# Deployment job
60+
deploy:
61+
environment:
62+
name: github-pages
63+
url: ${{ steps.deployment.outputs.page_url }}
64+
runs-on: ubuntu-latest
65+
needs: build
66+
if: github.ref == 'refs/heads/main'
67+
steps:
68+
- name: Deploy to GitHub Pages
69+
id: deployment
70+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)