Skip to content

Commit b3c5edd

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

File tree

3 files changed

+155
-8
lines changed

3 files changed

+155
-8
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: 116 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,126 @@ 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: Debug changed files outputs
64+
shell: bash
65+
run: |
66+
echo "=== Debug: changed-files action outputs ==="
67+
echo "Core changed: '${{ steps.changes.outputs.core }}'"
68+
echo "Core changed any: '${{ steps.changes.outputs.core_any_changed }}'"
69+
echo "All outputs JSON:"
70+
echo '${{ toJSON(steps.changes.outputs) }}'
71+
echo "============================================="
72+
73+
- name: Generate deployment matrix
74+
id: generate-matrix
75+
shell: bash
76+
run: |
77+
# Read locale config
78+
locale_config=$(cat .github/locales-config.json)
79+
80+
# Initialize matrix
81+
matrix_include="[]"
82+
83+
echo "=== Debug: All changes outputs ==="
84+
changes_json='${{ toJSON(steps.changes.outputs) }}'
85+
echo "Changes JSON: $changes_json"
86+
87+
# Check what keys were actually changed
88+
echo "Changed keys: $(echo "$changes_json" | jq -r '.changed_keys // "none"')"
89+
echo "Modified keys: $(echo "$changes_json" | jq -r '.modified_keys // "none"')"
90+
echo "=================================="
91+
92+
# Check core changes - use the correct output format for files_yaml
93+
core_changed="${{ steps.changes.outputs.core_any_changed }}"
94+
95+
echo "Core changed: '$core_changed'"
96+
97+
# Check each locale dynamically from config
98+
for locale in $(echo "$locale_config" | jq -r 'keys[]'); do
99+
# Get locale configuration
100+
enabled=$(echo "$locale_config" | jq -r ".[\"$locale\"].enabled")
101+
secret_project_id=$(echo "$locale_config" | jq -r ".[\"$locale\"].secret_project_id")
102+
103+
# Get locale change status dynamically from the changes JSON
104+
# Use the correct output format: {locale}_any_changed
105+
locale_changed=$(echo "$changes_json" | jq -r ".[\"${locale}_any_changed\"] // \"false\"")
106+
107+
echo "Checking $locale: enabled=$enabled, changed=$locale_changed, core_changed=$core_changed"
108+
109+
# Add to matrix if enabled and (core changed or locale changed)
110+
if [ "$enabled" == "true" ] && ([ "$core_changed" == "true" ] || [ "$locale_changed" == "true" ]); then
111+
echo "Adding $locale to deployment matrix"
112+
matrix_include=$(echo "$matrix_include" | jq --arg locale "$locale" --arg secret_id "$secret_project_id" '. + [{"locale": $locale, "secret_project_id": $secret_id}]')
113+
fi
114+
done
115+
116+
echo "Final matrix: $matrix_include"
117+
118+
# Ensure the matrix is properly formatted as a single line
119+
matrix_output=$(echo "$matrix_include" | jq -c '.')
120+
echo "Matrix output (compact): $matrix_output"
121+
echo "include=$matrix_output" >> $GITHUB_OUTPUT
122+
10123
deploy-and-update-index:
124+
needs: check-changes
125+
if: needs.check-changes.outputs.matrix-include != '[]'
11126
runs-on: ubuntu-latest
12127
strategy:
13128
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
129+
include: ${{ fromJson(needs.check-changes.outputs.matrix-include) }}
21130
name: Deploy ${{ matrix.locale }}
22131
steps:
23132
- name: Checkout code

apps/docs/messages/zh-hans.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"baseOptions": {
3-
"title": "Next.js 简体中文",
3+
"title": "Next.js - 简体中文",
44
"doc": "文档",
55
"blog": "博客",
66
"learn": "学习"

0 commit comments

Comments
 (0)