Skip to content

Commit 158ad7d

Browse files
committed
feat: release action config
1 parent 0140a32 commit 158ad7d

File tree

2 files changed

+144
-7
lines changed

2 files changed

+144
-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: 106 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,116 @@ 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+
# Debug: Also log the exact content that will be passed to changed-files
46+
echo "=== Debug: files_yaml content ==="
47+
echo "$files_yaml"
48+
echo "================================="
49+
50+
# Save to output for next step
51+
{
52+
echo "files_yaml<<EOF"
53+
echo "$files_yaml"
54+
echo "EOF"
55+
} >> $GITHUB_OUTPUT
56+
57+
- name: Get changed files with dynamic config
58+
id: changes
59+
uses: tj-actions/changed-files@v41
60+
with:
61+
files_yaml: ${{ steps.generate-files-config.outputs.files_yaml }}
62+
63+
- name: Generate deployment matrix
64+
id: generate-matrix
65+
shell: bash
66+
run: |
67+
# Read locale config
68+
locale_config=$(cat .github/locales-config.json)
69+
70+
# Initialize matrix
71+
matrix_include="[]"
72+
73+
echo "=== Debug: All changes outputs ==="
74+
changes_json='${{ toJSON(steps.changes.outputs) }}'
75+
echo "Changes JSON: $changes_json"
76+
77+
# Check what keys were actually changed
78+
echo "Changed keys: $(echo "$changes_json" | jq -r '.changed_keys // "none"')"
79+
echo "Modified keys: $(echo "$changes_json" | jq -r '.modified_keys // "none"')"
80+
echo "=================================="
81+
82+
# Check core changes - use the correct output format for files_yaml
83+
core_changed="${{ steps.changes.outputs.core_any_changed }}"
84+
85+
echo "Core changed: '$core_changed'"
86+
87+
# Check each locale dynamically from config
88+
for locale in $(echo "$locale_config" | jq -r 'keys[]'); do
89+
# Get locale configuration
90+
enabled=$(echo "$locale_config" | jq -r ".[\"$locale\"].enabled")
91+
secret_project_id=$(echo "$locale_config" | jq -r ".[\"$locale\"].secret_project_id")
92+
93+
# Get locale change status dynamically from the changes JSON
94+
# Use the correct output format: {locale}_any_changed
95+
locale_changed=$(echo "$changes_json" | jq -r ".[\"${locale}_any_changed\"] // \"false\"")
96+
97+
echo "Checking $locale: enabled=$enabled, changed=$locale_changed, core_changed=$core_changed"
98+
99+
# Add to matrix if enabled and (core changed or locale changed)
100+
if [ "$enabled" == "true" ] && ([ "$core_changed" == "true" ] || [ "$locale_changed" == "true" ]); then
101+
echo "Adding $locale to deployment matrix"
102+
matrix_include=$(echo "$matrix_include" | jq --arg locale "$locale" --arg secret_id "$secret_project_id" '. + [{"locale": $locale, "secret_project_id": $secret_id}]')
103+
fi
104+
done
105+
106+
echo "Final matrix: $matrix_include"
107+
108+
# Ensure the matrix is properly formatted as a single line
109+
matrix_output=$(echo "$matrix_include" | jq -c '.')
110+
echo "Matrix output (compact): $matrix_output"
111+
echo "include=$matrix_output" >> $GITHUB_OUTPUT
112+
10113
deploy-and-update-index:
114+
needs: check-changes
115+
if: needs.check-changes.outputs.matrix-include != '[]'
11116
runs-on: ubuntu-latest
12117
strategy:
13118
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
119+
include: ${{ fromJson(needs.check-changes.outputs.matrix-include) }}
21120
name: Deploy ${{ matrix.locale }}
22121
steps:
23122
- name: Checkout code

0 commit comments

Comments
 (0)