189 lines (183 loc) · 7.56 KB
/
deploy.pages.yml
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
name: deploy (GitHub Pages)
on:
workflow_call:
inputs:
application_name:
description: 'The application to deploy'
required: false
default: www
type: string
deployment_environment:
description: 'The targeted `DEPLOYMENT_ENVIRONMENT`'
required: false
default: dev
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
GH_PAGES_DEPLOYMENT_TOKEN:
required: true
workflow_dispatch:
inputs:
application_name:
description: 'The application to deploy'
required: true
default: www
type: choice
options:
- www
- jsonresume-theme
deployment_environment:
description: 'The targeted `DEPLOYMENT_ENVIRONMENT`'
required: true
default: dev
type: choice
options:
- dev
- prd
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
GH_PAGES_DEPLOYMENT_TOKEN:
required: true
jobs:
deploy:
name: Run `yarn deploy`
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
DEPLOY: true
APPLICATION_NAME: ${{ github.event.inputs.application_name || inputs.application_name }}
DEPLOYMENT_ENVIRONMENT: ${{ github.event.inputs.deployment_environment || inputs.deployment_environment }}
GITHUB_ACTIONS_AUTHOR_EMAIL: github@randytarampi.ca
GITHUB_ACTIONS_AUTHOR_NAME: deploy.pages
runs-on:
- ubuntu-latest
concurrency: deploy-${{ github.ref }}
steps:
- name: Set variables
id: variables
run: |
echo "::set-output name=application_name::$APPLICATION_NAME"
echo "::set-output name=deployment_environment::$DEPLOYMENT_ENVIRONMENT"
echo "NODE_ENV=$DEPLOYMENT_ENVIRONMENT" >> $GITHUB_ENV
echo "PRINTABLE_PUPPETEER_NO_SANDBOX=$CI" >> $GITHUB_ENV
echo "CPU_ARCH=$RUNNER_ARCH" >> $GITHUB_ENV
echo "OS_NAME=$RUNNER_OS" >> $GITHUB_ENV
echo "BRANCH=$GITHUB_REF_NAME" >> $GITHUB_ENV
echo "COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
echo "BUILD_NUMBER=$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "JOB_NUMBER=$GITHUB_RUN_ATTEMPT" >> $GITHUB_ENV
- name: Run `git checkout`
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup node@12
uses: actions/setup-node@v2
with:
node-version: "12"
- name: Setup dependencies on build runner
run: |
sudo apt-get update
sudo apt-get install language-pack-ja japan* fonts-wqy-microhei ttf-wqy-microhei
# NOTE-RT: Rerun `install` to make sure we've got our dependencies
- name: Install `yarn`
run: |
npm install -g yarn@1
yarn config set script-shell $(which bash)
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash
- name: Restore `node_modules` cache
uses: actions/cache@v2
id: yarn-cache
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-
${{ runner.os }}-yarn-
- name: Actually run `yarn install --frozen-lockfile`
run: yarn install --frozen-lockfile
- name: Setup for deployment
uses: chrnorm/deployment-action@releases/v1
id: deployment
with:
token: ${{ github.token }}
environment: ${{ steps.variables.outputs.deployment_environment }}
description: '`${{ steps.variables.outputs.application_name }}` @ ${{ github.event.push.compare }}'
- name: Build `docs`
env:
BABEL_ENV: production
run: |
yarn lerna run resume --scope=jsonresume-theme-*;
yarn lerna run docs --scope="*/${{ steps.variables.outputs.application_name }}" --scope="*${{ steps.variables.outputs.application_name }}*"
- name: Adjust `docs` for `dev`
if: ${{ steps.variables.outputs.deployment_environment == 'dev' && steps.variables.outputs.application_name == 'www' }}
run: |
git config --local user.email "$GITHUB_ACTIONS_AUTHOR_EMAIL"
git config --local user.name "$GITHUB_ACTIONS_AUTHOR_NAME"
echo "www.dev.randytarampi.ca" > packages/${{ steps.variables.outputs.application_name }}/docs/CNAME;
if [ -d "packages/${{ steps.variables.outputs.application_name }}/docs" ]; then git add --verbose --force --all packages/${{ steps.variables.outputs.application_name }}/docs; fi;
if [[ -n $(git status -s) ]]; then git commit -m "release: Prepare to deploy \`${{ steps.variables.outputs.application_name }}\` to ${{ github.repository_owner }}.github.io.git"; fi;
- name: Actually deploy (www/dev)
if: ${{ steps.variables.outputs.deployment_environment }} == 'dev' && ${{ steps.variables.outputs.application_name }} == 'www'
uses: JamesIves/github-pages-deploy-action@v4.3.0
with:
git-config-email: ${{ env.GITHUB_ACTIONS_AUTHOR_EMAIL }}
git-config-name: ${{ env.GITHUB_ACTIONS_AUTHOR_NAME }} (www/dev)
force: true
clean: true
branch: master
folder: packages/${{ steps.variables.outputs.application_name }}/docs
repository-name: ${{ github.repository_owner }}/${{ github.repository_owner }}.github.io
token: ${{ secrets.GH_PAGES_DEPLOYMENT_TOKEN }}
timeout-minutes: 10
- name: Actually deploy (www/prd)
if: ${{ steps.variables.outputs.deployment_environment == 'prd' && steps.variables.outputs.application_name == 'www' }}
uses: JamesIves/github-pages-deploy-action@v4.3.0
with:
git-config-email: ${{ env.GITHUB_ACTIONS_AUTHOR_EMAIL }}
git-config-name: ${{ env.GITHUB_ACTIONS_AUTHOR_NAME }} (www/prd)
single-commit: true
force: true
clean: true
branch: gh-pages
folder: packages/${{ steps.variables.outputs.application_name }}/docs
timeout-minutes: 10
- name: Actually deploy (jsonresume-theme/prd)
if: ${{ steps.variables.outputs.deployment_environment == 'prd' && steps.variables.outputs.application_name == 'jsonresume-theme' }}
uses: JamesIves/github-pages-deploy-action@v4.3.0
with:
git-config-email: ${{ env.GITHUB_ACTIONS_AUTHOR_EMAIL }}
git-config-name: ${{ env.GITHUB_ACTIONS_AUTHOR_NAME }} (jsonresult-theme/prd)
force: true
clean: true
branch: master
folder: packages/${{ steps.variables.outputs.application_name }}/docs
repository-name: ${{ github.repository_owner }}/me.resume
token: ${{ secrets.GH_PAGES_DEPLOYMENT_TOKEN }}
timeout-minutes: 10
- name: Handle deployment (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ github.token }}
state: success
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: Handle deployment (failure)
if: failure()
uses: chrnorm/deployment-status@releases/v1
with:
token: ${{ github.token }}
state: failure
deployment_id: ${{ steps.deployment.outputs.deployment_id }}