77 workflows : ["Translate docs"]
88 types : [completed]
99 branches : [main]
10+
1011jobs :
12+ # ──────────────────────────────────────────────────────────────
13+ # Determine whether this is a translation-only deploy
14+ # ──────────────────────────────────────────────────────────────
15+ classify :
16+ runs-on : ubuntu-latest
17+ if : github.event_name == 'push' || github.event.workflow_run.conclusion == 'success'
18+ outputs :
19+ translation_only : ${{ steps.check.outputs.translation_only }}
20+ steps :
21+ - uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 2
24+ - id : check
25+ run : |
26+ if [ "${{ github.event_name }}" = "workflow_run" ]; then
27+ echo "translation_only=true" >> $GITHUB_OUTPUT
28+ else
29+ # Check if the commit is a translation-only commit (from the bot)
30+ AUTHOR=$(git log -1 --pretty=format:'%an')
31+ MSG=$(git log -1 --pretty=format:'%s')
32+ if [[ "$AUTHOR" == "github-actions[bot]" && "$MSG" == "chore: update translations" ]]; then
33+ echo "translation_only=true" >> $GITHUB_OUTPUT
34+ else
35+ echo "translation_only=false" >> $GITHUB_OUTPUT
36+ fi
37+ fi
38+
1139 check-internal-links :
1240 name : Check internal links
41+ needs : classify
42+ if : needs.classify.outputs.translation_only == 'false'
1343 runs-on : ubuntu-latest
14- if : github.event_name == 'push' || github.event.workflow_run.conclusion == 'success'
1544 steps :
1645 - uses : actions/checkout@v4
1746 with :
@@ -22,23 +51,109 @@ jobs:
2251 - run : npm install github-slugger
2352 - run : node scripts/check-links/index.mjs --diff --base=last-production-deploy --internal-only
2453
25- deploy :
54+ # ──────────────────────────────────────────────────────────────
55+ # Full deploy: English + all locales (on content pushes)
56+ # ──────────────────────────────────────────────────────────────
57+ build-en :
58+ needs : check-internal-links
59+ runs-on : ubuntu-latest
60+ steps :
61+ - uses : actions/checkout@v4
62+
63+ - uses : actions/setup-node@v4
64+ with :
65+ node-version : 20
66+
67+ - name : Cache node_modules
68+ uses : actions/cache@v4
69+ with :
70+ path : node_modules
71+ key : npm-${{ hashFiles('package-lock.json') }}
72+
73+ - name : Cache Astro build
74+ uses : actions/cache@v4
75+ with :
76+ path : .astro
77+ key : astro-en-${{ github.sha }}
78+ restore-keys : astro-en-
79+
80+ - run : npm ci
81+
82+ - name : Build English only
83+ run : ASTRO_TELEMETRY_DISABLED=1 BUILD_LOCALES=none astro build
84+
85+ - name : Generate markdown exports
86+ run : npm run build:md:prod
87+
88+ - uses : actions/upload-artifact@v4
89+ with :
90+ name : build-en
91+ path : build/
92+ retention-days : 1
93+
94+ build-locale-full :
2695 needs : check-internal-links
2796 runs-on : ubuntu-latest
97+ strategy :
98+ matrix :
99+ locale : [zh, tr]
100+ steps :
101+ - uses : actions/checkout@v4
102+
103+ - uses : actions/setup-node@v4
104+ with :
105+ node-version : 20
106+
107+ - name : Cache node_modules
108+ uses : actions/cache@v4
109+ with :
110+ path : node_modules
111+ key : npm-${{ hashFiles('package-lock.json') }}
112+
113+ - name : Cache Astro build
114+ uses : actions/cache@v4
115+ with :
116+ path : .astro
117+ key : astro-${{ matrix.locale }}-${{ github.sha }}
118+ restore-keys : astro-${{ matrix.locale }}-
119+
120+ - run : npm ci
121+
122+ - name : Build locale ${{ matrix.locale }}
123+ run : ASTRO_TELEMETRY_DISABLED=1 BUILD_LOCALES=${{ matrix.locale }} astro build
124+
125+ - uses : actions/upload-artifact@v4
126+ with :
127+ name : build-${{ matrix.locale }}
128+ path : build/${{ matrix.locale }}/
129+ retention-days : 1
130+
131+ deploy-full :
132+ needs : [build-en, build-locale-full]
133+ runs-on : ubuntu-latest
28134 permissions :
29135 contents : write
30136 environment : production
31137 env :
32138 AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
33139 AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
34140 steps :
35- - uses : actions/checkout@v3
141+ - uses : actions/checkout@v4
36142
37- - name : Install dependencies
38- run : npm ci
143+ - uses : actions/download-artifact@v4
144+ with :
145+ name : build-en
146+ path : build/
147+
148+ - uses : actions/download-artifact@v4
149+ with :
150+ name : build-zh
151+ path : build/zh/
39152
40- - name : Build
41- run : ASTRO_TELEMETRY_DISABLED=1 npm run build
153+ - uses : actions/download-artifact@v4
154+ with :
155+ name : build-tr
156+ path : build/tr/
42157
43158 - name : Deploy
44159 uses : reggionick/s3-deploy@v4
@@ -49,9 +164,88 @@ jobs:
49164 dist-id : ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
50165 invalidation : /*
51166 delete-removed : true
52- # no-cache: true
53167 private : true
54- # files-to-include: '{.*/**,**}'
168+
169+ - name : Update deployment tag
170+ run : |
171+ git tag -f last-production-deploy
172+ git push -f origin last-production-deploy
173+
174+ # ──────────────────────────────────────────────────────────────
175+ # Translation-only deploy: build + upload only locale dirs
176+ # ──────────────────────────────────────────────────────────────
177+ build-locale-only :
178+ needs : classify
179+ if : needs.classify.outputs.translation_only == 'true'
180+ runs-on : ubuntu-latest
181+ strategy :
182+ matrix :
183+ locale : [zh, tr]
184+ steps :
185+ - uses : actions/checkout@v4
186+
187+ - uses : actions/setup-node@v4
188+ with :
189+ node-version : 20
190+
191+ - name : Cache node_modules
192+ uses : actions/cache@v4
193+ with :
194+ path : node_modules
195+ key : npm-${{ hashFiles('package-lock.json') }}
196+
197+ - name : Cache Astro build
198+ uses : actions/cache@v4
199+ with :
200+ path : .astro
201+ key : astro-${{ matrix.locale }}-${{ github.sha }}
202+ restore-keys : astro-${{ matrix.locale }}-
203+
204+ - run : npm ci
205+
206+ - name : Build locale ${{ matrix.locale }}
207+ run : ASTRO_TELEMETRY_DISABLED=1 BUILD_LOCALES=${{ matrix.locale }} astro build
208+
209+ - uses : actions/upload-artifact@v4
210+ with :
211+ name : build-tr-only-${{ matrix.locale }}
212+ path : build/${{ matrix.locale }}/
213+ retention-days : 1
214+
215+ deploy-translations :
216+ needs : build-locale-only
217+ runs-on : ubuntu-latest
218+ permissions :
219+ contents : write
220+ environment : production
221+ env :
222+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
223+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
224+ steps :
225+ - uses : actions/checkout@v4
226+
227+ - uses : actions/download-artifact@v4
228+ with :
229+ name : build-tr-only-zh
230+ path : build/zh/
231+
232+ - uses : actions/download-artifact@v4
233+ with :
234+ name : build-tr-only-tr
235+ path : build/tr/
236+
237+ # Sync locale directories to S3 using AWS CLI —
238+ # only overwrites zh/ and tr/ prefixes, leaves English untouched.
239+ - name : Deploy translations to S3
240+ run : |
241+ aws s3 sync build/zh/ s3://${{ secrets.S3_BUCKET }}/zh/ --delete
242+ aws s3 sync build/tr/ s3://${{ secrets.S3_BUCKET }}/tr/ --delete
243+
244+ - name : Invalidate locale paths
245+ run : |
246+ aws cloudfront create-invalidation \
247+ --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
248+ --paths "/zh/*" "/tr/*"
55249
56250 - name : Update deployment tag
57251 run : |
0 commit comments