File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 contents : read
1414 pages : write
1515 id-token : write
16+ pull-requests : write
1617
1718 steps :
1819 - name : Checkout
5051 - name : Deploy to GitHub Pages
5152 id : deployment
5253 uses : actions/deploy-pages@v4
54+ - name : Comment PR with preview URL
55+ if : github.event_name == 'pull_request'
56+ uses : actions/github-script@v7
57+ with :
58+ github-token : ${{ secrets.GITHUB_TOKEN }}
59+ script : |
60+ const pr = context.payload.pull_request.number;
61+ const url = process.env.PREVIEW_URL;
62+ await github.rest.issues.createComment({
63+ owner: context.repo.owner,
64+ repo: context.repo.repo,
65+ issue_number: pr,
66+ body: `Preview this PR: ${url}`
67+ });
68+ env :
69+ PREVIEW_URL : ${{ steps.deployment.outputs.page_url }}
70+
Original file line number Diff line number Diff line change 7070## 🚀 部署说明
7171
7272本项目采用 GitHub Actions 自动化部署到 GitHub Pages,每次推送到主分支时自动构建和部署。
73+ 在每个 Pull Request 上也会自动构建预览,并在 PR 评论中提供访问链接。
7374
7475如需 fork 此项目进行自定义开发:
7576
You can’t perform that action at this time.
0 commit comments