-
Notifications
You must be signed in to change notification settings - Fork 16
190 lines (177 loc) · 7.5 KB
/
Copy pathnode-dev.js.yml
File metadata and controls
190 lines (177 loc) · 7.5 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
# 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 }}
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 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- 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 renderer dependency
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ] && [ -n "${{ github.event.client_payload.renderer_version }}" ]; then
npm install @abstractplay/renderer@${{ github.event.client_payload.renderer_version }}
else
npm install @abstractplay/renderer@development
fi
- run: npm list @abstractplay/renderer
- run: npm list @svgdotjs/svg.js
- run: ls node_modules | grep @svgdotjs
- run: npm test --if-present
# --- MACHINE TRANSLATION PIPELINE START ---
- 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]"
file_pattern: 'locales/{de,fr,it}/*.json locale-src/{de,fr,it}/*.json'
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")
npm pkg set "dependencies.@abstractplay/renderer=$RENDERER_VERSION"
echo "gameslib_version=$GAMESLIB_VERSION" >> $GITHUB_OUTPUT
echo "renderer_version=$RENDERER_VERSION" >> $GITHUB_OUTPUT
- run: npm run build
- run: npm pack
- name: Upload
uses: actions/upload-artifact@v4
with:
name: package
path: "*.tgz"
- name: Trigger docs rebuild
if: github.event_name == 'push'
run: |
if git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | 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: 18.x
registry-url: https://npm.pkg.github.com/
scope: "@abstractplay"
- 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 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'npm'
- 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
- run: npm install @abstractplay/renderer@development
- 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 }}
SOURCE_RUN_ID: ${{ needs.build-dev.outputs.source_run_id }}
run: |
payload=$(jq -n \
--arg g "$GAMESLIB_VERSION" \
--arg r "$RENDERER_VERSION" \
--arg s "$SOURCE_RUN_ID" \
'{event_type:"dep_update_dev", client_payload:{gameslib_version:$g, renderer_version:$r, source_run_id:$s}}')
for repo in front node-backend backend-crons backend-thumbnails; 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