|
1 | | -name: Vercel Preview Deployment |
| 1 | +name: Pre-release |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
5 | | - push: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + types: [labeled] |
6 | 7 | branches-ignore: |
7 | 8 | - main |
8 | 9 |
|
9 | 10 | jobs: |
10 | 11 | deploy-en: |
| 12 | + if: github.event.label.name == 'prerelease' |
11 | 13 | uses: ./.github/workflows/vercel-deploy.yml |
12 | 14 | with: |
13 | 15 | environment: preview |
|
18 | 20 | VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
19 | 21 |
|
20 | 22 | deploy-zh-hans: |
| 23 | + if: github.event.label.name == 'prerelease' |
21 | 24 | uses: ./.github/workflows/vercel-deploy.yml |
22 | 25 | with: |
23 | 26 | environment: preview |
|
26 | 29 | VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ZH_HANS_ID }} |
27 | 30 | VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} |
28 | 31 | VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |
| 32 | + |
| 33 | + comment-vercel-preview: |
| 34 | + if: github.event.label.name == 'prerelease' |
| 35 | + needs: [deploy-en, deploy-zh-hans] |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Comment PR with Vercel Preview Links |
| 39 | + uses: actions/github-script@v7 |
| 40 | + with: |
| 41 | + script: | |
| 42 | + const en_inspect = process.env.EN_INSPECT_URL; |
| 43 | + const en_prod = process.env.EN_PROD_URL; |
| 44 | + const zh_inspect = process.env.ZH_INSPECT_URL; |
| 45 | + const zh_prod = process.env.ZH_PROD_URL; |
| 46 | + let body = `**Vercel Deploy Preview**\n\n`; |
| 47 | + body += `- 🇺🇸 EN: [Inspect](${en_inspect}) | [Preview](${en_prod})\n`; |
| 48 | + body += `- 🇨🇳 ZH-HANS: [Inspect](${zh_inspect}) | [Preview](${zh_prod})`; |
| 49 | + github.rest.issues.createComment({ |
| 50 | + issue_number: context.issue.number, |
| 51 | + owner: context.repo.owner, |
| 52 | + repo: context.repo.repo, |
| 53 | + body |
| 54 | + }); |
| 55 | + env: |
| 56 | + EN_INSPECT_URL: ${{ needs.deploy-en.outputs.inspect_url }} |
| 57 | + EN_PROD_URL: ${{ needs.deploy-en.outputs.prod_url }} |
| 58 | + ZH_INSPECT_URL: ${{ needs.deploy-zh-hans.outputs.inspect_url }} |
| 59 | + ZH_PROD_URL: ${{ needs.deploy-zh-hans.outputs.prod_url }} |
0 commit comments