@@ -14,7 +14,6 @@ permissions:
1414
1515jobs :
1616 deploy :
17- if : contains(github.event.pull_request.labels.*.name, 'prerelease')
1817 runs-on : ubuntu-latest
1918 strategy :
2019 matrix :
@@ -27,13 +26,32 @@ jobs:
2726 secret_project_id : VERCEL_PROJECT_ZH_HANT_ID
2827 name : Deploy ${{ matrix.locale }}
2928 steps :
29+ # Calculate if this matrix job should run based on PR labels
30+ - name : Calculate should_deploy
31+ id : should_deploy
32+ shell : bash
33+ run : |
34+ LABELS="${{ toJson(github.event.pull_request.labels.*.name) }}"
35+ echo "LABELS: $LABELS"
36+ SHOULD_DEPLOY=false
37+ if [[ "${{ github.event_name }}" != "pull_request" ]]; then
38+ SHOULD_DEPLOY=true
39+ elif echo "$LABELS" | grep -q '"prerelease"'; then
40+ SHOULD_DEPLOY=true
41+ elif echo "$LABELS" | grep -q "\"prerelease:${{ matrix.locale }}\""; then
42+ SHOULD_DEPLOY=true
43+ fi
44+ echo "should_deploy=$SHOULD_DEPLOY" >> $GITHUB_OUTPUT
3045 - name : Checkout code
46+ if : steps.should_deploy.outputs.should_deploy == 'true'
3147 uses : actions/checkout@v3
3248 with :
3349 fetch-depth : 1
3450 - name : Setup Tools
51+ if : steps.should_deploy.outputs.should_deploy == 'true'
3552 uses : ./.github/actions/setup
3653 - name : Deploy to Vercel (${{ matrix.locale }})
54+ if : steps.should_deploy.outputs.should_deploy == 'true'
3755 id : deploy
3856 uses : ./.github/actions/vercel-deploy
3957 with :
4260 vercel_org_id : ${{ secrets.VERCEL_ORG_ID }}
4361 vercel_token : ${{ secrets.VERCEL_TOKEN }}
4462 - name : Comment PR with Vercel Preview Links (${{ matrix.locale }})
63+ if : steps.should_deploy.outputs.should_deploy == 'true'
4564 uses : ./.github/actions/comment-vercel-preview
4665 with :
4766 inspect_url : ${{ steps.deploy.outputs.inspect_url }}
0 commit comments