Repository navigation
165 lines (141 loc) · 5.59 KB
/
Copy pathdeploy-dev.js.yml
File metadata and controls
165 lines (141 loc) · 5.59 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
#
# Github Actions for Serverless Framework
#
# Create AWS_KEY and AWS_SECRET secrets in Github repository settings
# If you're using env.yml file, store its content as ENV Github secret
#
# Master branch will be deployed as DEV and every new tag starting with "v**" (e.g. v1.0, v1.2, v2.0, etc) will be deployed as PROD
#
# Learn more: https://maxkostinevich.com/blog/how-to-deploy-serverless-applications-using-github-actions/
#
name: Deploy Dev
on:
push:
branches:
- develop
repository_dispatch:
types: [dep_update_dev]
workflow_dispatch:
concurrency:
group: deploy-dev
cancel-in-progress: true
jobs:
test:
uses: ./.github/workflows/ci-test.yml
with:
ap_deps_stage: dev
ap_gameslib_version: ${{ github.event.client_payload.gameslib_version }}
ap_renderer_version: ${{ github.event.client_payload.renderer_version }}
ap_source: ${{ github.event.client_payload.source_run_id && format('gameslib-ci-{0}', github.event.client_payload.source_run_id) || '' }}
secrets:
PAT_READ_PACKAGES: ${{ secrets.PAT_READ_PACKAGES }}
deploy-dev:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
env:
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
SERVERLESS_ORG: abstractplay
steps:
- uses: actions/checkout@v4
with:
ref: "develop"
- uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
- name: Pin npm
run: npm install -g npm@11.6.2
- name: Create .npmrc
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
- name: Install NPM dependencies
run: npm ci
- name: Validate ci-deps manifests
run: npx ap-check-ci-deps
- name: Install pinned AP dependencies
env:
AP_GAMESLIB_VERSION: ${{ github.event.client_payload.gameslib_version }}
AP_RENDERER_VERSION: ${{ github.event.client_payload.renderer_version }}
AP_SOURCE: ${{ github.event.client_payload.source_run_id && format('gameslib-ci-{0}', github.event.client_payload.source_run_id) || '' }}
run: npx ap-install-deps --stage dev
- name: Verify lockfile matches ci-deps
run: npx ap-check-ci-deps --stage dev --strict
- name: Sync dependency manifests
if: github.event_name == 'repository_dispatch'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "deps: sync AP versions [skip ci]"
# git-auto-commit `read -a` only uses the first line of multiline inputs — space-separate patterns.
file_pattern: "ci-deps.dev.json package-lock.json package.json"
# --- MACHINE TRANSLATION PIPELINE START ---
- name: Prune stale managed locale keys
run: node bin/locale-prune.mjs public/locales/en/apfront.json
- name: Run Machine Translation on Locales
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: node bin/translate.mjs public/locales/en/apfront.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/*/*.json locale-src/**/*.json"
# --- MACHINE TRANSLATION PIPELINE END ---
- name: Set CI version
run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version
- name: Build
run: npm run build-dev
env:
CI: false
- 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}}
# uses: aws-actions/configure-aws-credentials@v2
# with:
# aws-access-key-id: ${{ secrets.AWS_KEY }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET }}
# aws-region: us-east-1
- name: Deploy
run: npx serverless client deploy --no-confirm
- name: Sync CloudFront CSP
run: node bin/sync-cloudfront-csp.mjs --stage dev
- name: Publish locale files to S3
run: node bin/publish-locales.mjs --stage dev
- 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
# Optional (to use with serverless-finch serverless plugin)
#- name: Deploy assets to S3
# run: sls client deploy --no-delete-contents --no-confirm -s dev