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