-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (118 loc) · 4.5 KB
/
Copy pathdeploy-dev.js.yml
File metadata and controls
136 lines (118 loc) · 4.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
#
# 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
env:
VAPID_PUBLIC_KEY: ${{ secrets.VAPID_PUBLIC_KEY }}
VAPID_PRIVATE_KEY: ${{ secrets.VAPID_PRIVATE_KEY }}
TOTP_KEY: ${{ secrets.TOTP_KEY }}
OPENSSH_PRIVATE_KEY: ${{ secrets.OPENSSH_PRIVATE_KEY }}
# Dev bot pool (us-east-1_kqlqXHDJ5) — separate from prod; update secrets after createBot / test-bot client rotation
TEST_BOT_CLIENT_ID: ${{ secrets.TEST_BOT_CLIENT_ID }}
TEST_BOT_CLIENT_SECRET: ${{ secrets.TEST_BOT_CLIENT_SECRET }}
jobs:
deploy-dev:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: "develop"
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
- name: Install Serverless Framework
run: npm install -g serverless@3.40.0
- name: Serverless AWS authentication
run: sls config credentials --provider aws --key ${{ secrets.AWS_KEY }} --secret ${{ secrets.AWS_SECRET }}
# - name: Create env file
# run: | # cp sample.env.yml env.yml
# cat > env.yml << EOF
# ${{ secrets.ENV }}
# EOF
- 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: Install NPM dependencies
run: npm ci
- 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: node bin/install-ap-deps.mjs --stage dev
- 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]"
file_pattern: |
ci-deps.json
package-lock.json
package.json
- name: Set CI version
run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version
- name: Build
run: npm run build
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: bash bin/serverless-deploy.sh dev AbstractPlayDev
- 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