@@ -29,15 +29,35 @@ jobs:
2929 - name : Generate matrix from locales config
3030 id : set-matrix
3131 run : |
32- # Read the locales config and generate matrix for enabled locales
33- MATRIX=$(jq -c '
32+ LABELS_JSON='${{ toJson(github.event.pull_request.labels.*.name) }}'
33+ echo "LABELS_JSON: $LABELS_JSON"
34+
35+ # Check if we should deploy all locales (general prerelease)
36+ SHOULD_DEPLOY_GENERAL=false
37+ if [[ "${{ github.event_name }}" != "pull_request" ]]; then
38+ SHOULD_DEPLOY_GENERAL=true
39+ elif echo "$LABELS_JSON" | grep -E '"prerelease"' > /dev/null; then
40+ SHOULD_DEPLOY_GENERAL=true
41+ fi
42+
43+ echo "Should deploy all locales: $SHOULD_DEPLOY_GENERAL"
44+
45+ # Read the locales config and generate matrix for enabled locales that should deploy
46+ MATRIX=$(jq -c --argjson should_deploy_general "$SHOULD_DEPLOY_GENERAL" --argjson labels "$LABELS_JSON" '
3447 to_entries |
3548 map(select(.value.enabled == true)) |
36- map({
37- locale: .key,
38- secret_project_id: .value.secret_project_id
39- })
49+ map(. as $item | {
50+ locale: $item.key,
51+ secret_project_id: $item.value.secret_project_id,
52+ should_deploy: (
53+ $should_deploy_general or
54+ ($labels | any(. == ("prerelease:" + $item.key)))
55+ )
56+ }) |
57+ map(select(.should_deploy == true)) |
58+ map({locale: .locale, secret_project_id: .secret_project_id})
4059 ' .github/locales-config.json)
60+
4161 echo "matrix={\"include\":$MATRIX}" >> $GITHUB_OUTPUT
4262 echo "Generated matrix: {\"include\":$MATRIX}"
4363
@@ -55,41 +75,16 @@ jobs:
5575 matrix : ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
5676 name : Deploy ${{ matrix.locale }}
5777 steps :
58- # Calculate if this matrix job should run based on PR labels
59- #
60- # This job will deploy if:
61- # - The event is NOT a pull_request (e.g., workflow_dispatch)
62- # - OR the PR has the label 'prerelease'
63- # - OR the PR has the label 'prerelease:<locale>' matching the current matrix locale
64- - name : Calculate should_deploy
65- id : should_deploy
66- shell : bash
67- run : |
68- LABELS_JSON='${{ toJson(github.event.pull_request.labels.*.name) }}'
69- echo "LABELS_JSON: $LABELS_JSON"
70- SHOULD_DEPLOY=false
71- if [[ "${{ github.event_name }}" != "pull_request" ]]; then
72- SHOULD_DEPLOY=true
73- elif echo "$LABELS_JSON" | grep -E '"prerelease"' > /dev/null; then
74- SHOULD_DEPLOY=true
75- elif echo "$LABELS_JSON" | grep -E '"prerelease:'"${{ matrix.locale }}"'"' > /dev/null; then
76- SHOULD_DEPLOY=true
77- fi
78- echo "should_deploy=$SHOULD_DEPLOY" >> $GITHUB_OUTPUT
7978 - name : Checkout code
80- if : steps.should_deploy.outputs.should_deploy == 'true'
8179 uses : actions/checkout@v3
8280 with :
8381 fetch-depth : 1
8482 ref : ${{ github.head_ref }}
8583 - name : Log checked out commit
86- if : steps.should_deploy.outputs.should_deploy == 'true'
8784 run : git log -1
8885 - name : Setup Tools
89- if : steps.should_deploy.outputs.should_deploy == 'true'
9086 uses : ./.github/actions/setup
9187 - name : Deploy to Vercel (${{ matrix.locale }})
92- if : steps.should_deploy.outputs.should_deploy == 'true'
9388 id : deploy
9489 uses : ./.github/actions/vercel-deploy
9590 with :
@@ -98,22 +93,19 @@ jobs:
9893 vercel_org_id : ${{ secrets.VERCEL_ORG_ID }}
9994 vercel_token : ${{ secrets.VERCEL_TOKEN }}
10095 - name : Set deploy outputs
101- if : steps.should_deploy.outputs.should_deploy == 'true'
10296 id : set_outputs
10397 run : |
10498 echo "preview_url=${{ steps.deploy.outputs.prod_url }}" >> $GITHUB_OUTPUT
10599 echo "inspect_url=${{ steps.deploy.outputs.inspect_url }}" >> $GITHUB_OUTPUT
106100 echo "label=${{ matrix.locale }}" >> $GITHUB_OUTPUT
107101 - name : Write deploy result to file
108- if : steps.should_deploy.outputs.should_deploy == 'true'
109102 run : |
110103 jq -n \
111104 --arg label "${{ steps.set_outputs.outputs.label }}" \
112105 --arg preview_url "${{ steps.set_outputs.outputs.preview_url }}" \
113106 --arg inspect_url "${{ steps.set_outputs.outputs.inspect_url }}" \
114107 '{label: $label, preview_url: $preview_url, inspect_url: $inspect_url}' > deploy-result.json
115108 - name : Upload deploy result artifact
116- if : steps.should_deploy.outputs.should_deploy == 'true'
117109 uses : actions/upload-artifact@v4
118110 with :
119111 name : deploy-result-${{ matrix.locale }}
0 commit comments