-
Notifications
You must be signed in to change notification settings - Fork 18
249 lines (235 loc) · 10.4 KB
/
Copy pathnode-dev.js.yml
File metadata and controls
249 lines (235 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Dev Server CI
on:
push:
branches: [ "develop" ]
repository_dispatch:
types: [dep_update_dev]
workflow_dispatch:
jobs:
build-dev:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
gameslib_version: ${{ steps.capture_versions.outputs.gameslib_version }}
renderer_version: ${{ steps.capture_versions.outputs.renderer_version }}
recranks_version: ${{ steps.capture_versions.outputs.recranks_version }}
source_run_id: ${{ github.run_id }}
# strategy:
# matrix:
# node-version: [16.x, 18.x, 20.x]
# # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
with:
ref: "develop"
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 24
cache: 'npm'
- name: Pin npm
run: npm install -g npm@11.6.2
- run: echo "@abstractplay:registry=https://npm.pkg.github.com/" >> .npmrc
- run: echo "//npm.pkg.github.com/:_authToken=${{secrets.PAT_READ_PACKAGES}}" >> .npmrc
- name: Reject merge conflict markers in dep files
run: |
if grep -r '^<<<<<<<' package.json package-lock.json ci-deps.dev.json ci-deps.prod.json 2>/dev/null; then
echo "Conflict markers found in dependency files"
exit 1
fi
- run: npm ci
- name: Validate ci-deps manifests
run: npx ap-check-ci-deps
- name: Install pinned AP dependencies
env:
AP_RENDERER_VERSION: ${{ github.event.client_payload.renderer_version }}
AP_RECRANKS_VERSION: ${{ github.event.client_payload.recranks_version }}
AP_SOURCE: ${{ github.event.client_payload.source_run_id && (github.event.client_payload.recranks_version && format('recranks-ci-{0}', github.event.client_payload.source_run_id) || format('renderer-ci-{0}', github.event.client_payload.source_run_id)) || '' }}
run: npx ap-install-deps --stage dev
- name: Verify package.json matches ci-deps
run: npx ap-check-ci-deps --stage dev --strict
- run: npm list @abstractplay/renderer
- run: npm list @svgdotjs/svg.js
- run: ls node_modules | grep @svgdotjs
- run: npm test --if-present
- name: Checkout docs site
if: github.event_name == 'push'
uses: actions/checkout@v4
with:
repository: AbstractPlay/docs
path: _ap_docs
token: ${{ secrets.PAT_READ_PACKAGES }}
submodules: recursive
- name: Docs link check
if: github.event_name == 'push'
env:
AP_DOCS_ROOT: _ap_docs
run: npm run docs:check
# --- MACHINE TRANSLATION PIPELINE START ---
- name: Prune stale managed locale keys
run: node scripts/locale-prune.mjs locales/en/apgames.json locales/en/apresults.json
- name: Run Machine Translation on Locales
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: node scripts/translate.mjs locales/en/apgames.json locales/en/apresults.json
- name: Auto-commit Updated Translations Back to Branch
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "i18n: Auto-translate locale files [skip ci]"
# Directory paths only — no globs/braces. git-auto-commit passes file_pattern
# to `git add` with disable_globbing, so `*.json` and `{de,fr,it}` never expand.
file_pattern: locales/de/ locales/fr/ locales/it/ locales/es-US/ locale-src/de/ locale-src/fr/ locale-src/it/ locale-src/es-US/
disable_globbing: true
- name: Verify locale-src was committed
run: |
if git status --porcelain locale-src/ | grep -q .; then
echo "::error::locale-src/ has unstaged changes after auto-commit — sidecar stamps were not pushed"
git status --porcelain locale-src/
exit 1
fi
- name: Upload translation debug artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: translate-debug-${{ github.run_id }}
path: bin/translate-debug/
if-no-files-found: ignore
# --- MACHINE TRANSLATION PIPELINE END ---
- name: Configure AWS credentials
uses: Fooji/create-aws-profile-action@v1
with:
profile: AbstractPlayDev
region: us-east-1
key: ${{ secrets.AWS_KEY }}
secret: ${{ secrets.AWS_SECRET }}
- name: Publish locale files to S3
run: node scripts/publish-locales.mjs --stage dev
# prerelease --preid=ci-$GITHUB_RUN_ID
- run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version
- id: capture_versions
run: |
GAMESLIB_VERSION=$(node -p "require('./package.json').version")
RENDERER_VERSION=$(node -p "require('./node_modules/@abstractplay/renderer/package.json').version")
RECRANKS_VERSION=$(node -p "require('./node_modules/@abstractplay/recranks/package.json').version")
echo "gameslib_version=$GAMESLIB_VERSION" >> $GITHUB_OUTPUT
echo "renderer_version=$RENDERER_VERSION" >> $GITHUB_OUTPUT
echo "recranks_version=$RECRANKS_VERSION" >> $GITHUB_OUTPUT
- name: Sync AP dependency pin manifests
if: github.event_name == 'repository_dispatch'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "deps: sync AP pins [skip ci]"
file_pattern: ci-deps.dev.json package-lock.json package.json
disable_globbing: true
- run: npm run build
- run: npm run test:postbuild
- run: npm pack
- run: npm run test:consumer
- name: Upload
uses: actions/upload-artifact@v4
with:
name: package
path: "*.tgz"
- name: Trigger docs rebuild
if: github.event_name == 'push'
run: |
BEFORE="${{ github.event.before }}"
SHA="${{ github.sha }}"
if [[ "$BEFORE" == "0000000000000000000000000000000000000000" ]]; then
CHANGED=""
for commit in ${{ join(github.event.commits.*.id, ' ') }}; do
git fetch --depth=1 origin "$commit"
CHANGED+="$(git show --name-only --pretty=format: "$commit")"$'\n'
done
else
git fetch --depth=1 origin "$BEFORE"
CHANGED="$(git diff --name-only "$BEFORE" "$SHA")"
fi
if echo "$CHANGED" | grep -q '^docs/'; then
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT_WORKFLOWS }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/AbstractPlay/docs/dispatches \
-d '{"event_type":"dep_update_dev"}'
fi
publish-dev:
needs: [build-dev]
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/download-artifact@v4
with:
name: package
- uses: actions/setup-node@v3
with:
node-version: 24
registry-url: https://npm.pkg.github.com/
scope: "@abstractplay"
- name: Pin npm
run: npm install -g npm@11.6.2
- run: echo "registry=https://npm.pkg.github.com/@abstractplay" > .npmrc
- run: npm publish $(ls *.tgz) --tag development
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
deploy-playground:
needs: [publish-dev]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: "develop"
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- name: Pin npm
run: npm install -g npm@11.6.2
- run: echo "@abstractplay:registry=https://npm.pkg.github.com/" >> .npmrc
- run: echo "//npm.pkg.github.com/:_authToken=${{secrets.PAT_READ_PACKAGES}}" >> .npmrc
- run: npm ci
- name: Install pinned AP dependencies
run: npx ap-install-deps --stage dev
- run: npm run dist-dev
- name: Configure AWS credentials
uses: Fooji/create-aws-profile-action@v1
with:
profile: AbstractPlayDev
region: us-east-1
key: ${{ secrets.AWS_KEY }}
secret: ${{ secrets.AWS_SECRET }}
- name: Deploy playground
env:
AWS_SDK_LOAD_CONFIG: "1"
AWS_PROFILE: AbstractPlayDev
run: npm run deploy:ci
relay-dev:
needs: [deploy-playground, build-dev]
runs-on: ubuntu-latest
steps:
- name: Trigger consumer rebuilds
env:
GAMESLIB_VERSION: ${{ needs.build-dev.outputs.gameslib_version }}
RENDERER_VERSION: ${{ needs.build-dev.outputs.renderer_version }}
RECRANKS_VERSION: ${{ needs.build-dev.outputs.recranks_version }}
SOURCE_RUN_ID: ${{ needs.build-dev.outputs.source_run_id }}
run: |
payload=$(jq -n \
--arg g "$GAMESLIB_VERSION" \
--arg r "$RENDERER_VERSION" \
--arg k "$RECRANKS_VERSION" \
--arg s "$SOURCE_RUN_ID" \
'{event_type:"dep_update_dev", client_payload:{gameslib_version:$g, renderer_version:$r, recranks_version:$k, source_run_id:$s}}')
for repo in front node-backend backend-crons; do
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT_WORKFLOWS }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/abstractplay/${repo}/dispatches" \
-d "$payload"
done