Skip to content

Commit 5675ac2

Browse files
committed
feat: release action config
1 parent 0140a32 commit 5675ac2

File tree

2 files changed

+128
-7
lines changed

2 files changed

+128
-7
lines changed

.github/locales-config.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"en": {
3+
"secret_project_id": "VERCEL_PROJECT_EN_ID",
4+
"enabled": true
5+
},
6+
"zh-hans": {
7+
"secret_project_id": "VERCEL_PROJECT_ZH_HANS_ID",
8+
"enabled": true
9+
},
10+
"zh-hant": {
11+
"secret_project_id": "VERCEL_PROJECT_ZH_HANT_ID",
12+
"enabled": true
13+
},
14+
"ar": {
15+
"secret_project_id": "VERCEL_PROJECT_AR_ID",
16+
"enabled": false
17+
},
18+
"de": {
19+
"secret_project_id": "VERCEL_PROJECT_DE_ID",
20+
"enabled": false
21+
},
22+
"es": {
23+
"secret_project_id": "VERCEL_PROJECT_ES_ID",
24+
"enabled": false
25+
},
26+
"fr": {
27+
"secret_project_id": "VERCEL_PROJECT_FR_ID",
28+
"enabled": false
29+
},
30+
"ja": {
31+
"secret_project_id": "VERCEL_PROJECT_JA_ID",
32+
"enabled": false
33+
},
34+
"ru": {
35+
"secret_project_id": "VERCEL_PROJECT_RU_ID",
36+
"enabled": false
37+
}
38+
}

.github/workflows/release.yml

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,100 @@ on:
77
- main
88

99
jobs:
10+
check-changes:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix-include: ${{ steps.generate-matrix.outputs.include }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Generate dynamic files config
21+
id: generate-files-config
22+
shell: bash
23+
run: |
24+
# Read locale config
25+
locale_config=$(cat .github/locales-config.json)
26+
27+
# Start with core files config
28+
files_yaml="core:
29+
- 'apps/docs/**'
30+
- 'packages/**'
31+
- '!apps/docs/content/**'
32+
- '!apps/docs/messages/**'"
33+
34+
# Add each locale from config dynamically
35+
for locale in $(echo "$locale_config" | jq -r 'keys[]'); do
36+
files_yaml="$files_yaml
37+
$locale:
38+
- 'apps/docs/content/$locale/**'
39+
- 'apps/docs/messages/$locale.json'"
40+
done
41+
42+
echo "Generated files_yaml:"
43+
echo "$files_yaml"
44+
45+
# Save to output for next step
46+
{
47+
echo "files_yaml<<EOF"
48+
echo "$files_yaml"
49+
echo "EOF"
50+
} >> $GITHUB_OUTPUT
51+
52+
- name: Get changed files with dynamic config
53+
id: changes
54+
uses: tj-actions/changed-files@v41
55+
with:
56+
files_yaml: ${{ steps.generate-files-config.outputs.files_yaml }}
57+
58+
- name: Generate deployment matrix
59+
id: generate-matrix
60+
shell: bash
61+
run: |
62+
# Read locale config
63+
locale_config=$(cat .github/locales-config.json)
64+
65+
# Initialize matrix
66+
matrix_include="[]"
67+
68+
# Check core changes
69+
core_changed="${{ steps.changes.outputs.core }}"
70+
71+
echo "Core changed: $core_changed"
72+
73+
# Get all change outputs as JSON for easier parsing
74+
changes_json='${{ toJSON(steps.changes.outputs) }}'
75+
76+
# Check each locale dynamically from config
77+
for locale in $(echo "$locale_config" | jq -r 'keys[]'); do
78+
# Get locale configuration
79+
enabled=$(echo "$locale_config" | jq -r ".[\"$locale\"].enabled")
80+
secret_project_id=$(echo "$locale_config" | jq -r ".[\"$locale\"].secret_project_id")
81+
82+
# Get locale change status dynamically from the changes JSON
83+
locale_changed=$(echo "$changes_json" | jq -r ".[\"$locale\"] // \"false\"")
84+
85+
echo "Checking $locale: enabled=$enabled, changed=$locale_changed, core_changed=$core_changed"
86+
87+
# Add to matrix if enabled and (core changed or locale changed)
88+
if [ "$enabled" == "true" ] && ([ "$core_changed" == "true" ] || [ "$locale_changed" == "true" ]); then
89+
echo "Adding $locale to deployment matrix"
90+
matrix_include=$(echo "$matrix_include" | jq --arg locale "$locale" --arg secret_id "$secret_project_id" '. + [{"locale": $locale, "secret_project_id": $secret_id}]')
91+
fi
92+
done
93+
94+
echo "Final matrix: $matrix_include"
95+
echo "include=$matrix_include" >> $GITHUB_OUTPUT
96+
1097
deploy-and-update-index:
98+
needs: check-changes
99+
if: needs.check-changes.outputs.matrix-include != '[]'
11100
runs-on: ubuntu-latest
12101
strategy:
13102
matrix:
14-
include:
15-
- locale: en
16-
secret_project_id: VERCEL_PROJECT_EN_ID
17-
- locale: zh-hans
18-
secret_project_id: VERCEL_PROJECT_ZH_HANS_ID
19-
- locale: zh-hant
20-
secret_project_id: VERCEL_PROJECT_ZH_HANT_ID
103+
include: ${{ fromJson(needs.check-changes.outputs.matrix-include) }}
21104
name: Deploy ${{ matrix.locale }}
22105
steps:
23106
- name: Checkout code

0 commit comments

Comments
 (0)