File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy Preview
2+
3+ on :
4+ pull_request :
5+
6+ jobs :
7+ preview :
8+ runs-on : ubuntu-latest
9+ steps :
10+ - uses : actions/checkout@v4
11+ - uses : actions/setup-node@v4
12+ with :
13+ node-version : ' 20'
14+ cache : ' npm'
15+ - run : npm install
16+ - run : npm run build
17+ - name : Deploy to Netlify
18+ id : netlify
19+ uses : netlify/actions/cli@master
20+ with :
21+ args : deploy --dir=dist --json
22+ env :
23+ NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
24+ NETLIFY_SITE_ID : ${{ secrets.NETLIFY_SITE_ID }}
25+ - name : Comment preview URL
26+ uses : actions/github-script@v7
27+ with :
28+ script : |
29+ const url = process.env.NETLIFY_URL || '${{ steps.netlify.outputs.NETLIFY_URL }}';
30+ if (url) {
31+ github.rest.issues.createComment({
32+ owner: context.repo.owner,
33+ repo: context.repo.repo,
34+ issue_number: context.issue.number,
35+ body: `🧪 Preview deployed: ${url}`
36+ });
37+ } else {
38+ core.warning('No preview URL found.');
39+ }
Original file line number Diff line number Diff line change 78783 . 选择 GitHub Actions 作为部署源
79794 . 推送代码时将自动触发构建和部署
8080
81+ ### PR 预览
82+
83+ 在每个 Pull Request 上,GitHub Actions 会使用 ** Netlify** 自动部署预览站点,并在 PR 中评论预览链接,方便开发者快速验证功能是否正常。要启用此功能,需要在仓库的 ` Secrets ` 中配置 ` NETLIFY_AUTH_TOKEN ` 和 ` NETLIFY_SITE_ID ` 。
84+
8185## 📝 使用指南
8286
8387### 🎯 快速上手
You can’t perform that action at this time.
0 commit comments