-
Notifications
You must be signed in to change notification settings - Fork 21
274 lines (253 loc) · 10.7 KB
/
deploy.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
---
name: Deployment
on:
workflow_dispatch:
inputs:
env:
description: "Deploy to (dev|prod|dev prod)"
required: true
default: "dev"
clean:
description: "Clean cache (yes|no)"
required: true
default: "no"
excludeSubfolder:
description: "Exclude a subfolder from deletion"
required: false
default: ""
index-mode:
description: 'Type of indexing. "index" to push to Algolia, "console" for dry run.'
required: true
default: "index"
type: choice
options:
- console
- index
jobs:
set-state:
runs-on: ubuntu-latest
outputs:
deploy_prod: ${{ contains(github.event.inputs.env, 'prod') }}
deploy_dev: ${{ contains(github.event.inputs.env, 'dev') }}
clean_cache: ${{ contains(github.event.inputs.clean, 'yes') }}
path_prefix: ${{ steps.get_path_prefix.outputs.path_prefix }}
branch_short_ref: ${{ steps.get_branch.outputs.branch }}
exclude_subfolder: ${{ github.event.inputs.excludeSubfolder }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get pathPrefix
uses: actions/github-script@v6
id: get_path_prefix
with:
script: |
const script = require('./.github/scripts/get-path-prefix.js');
script({ core });
result-encoding: string
- name: Get branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
id: get_branch
echo-state:
needs: [set-state]
runs-on: ubuntu-latest
steps:
- run: echo "Deploy to dev - ${{ needs.set-state.outputs.deploy_dev }}"
- run: echo "Deploy to prod - ${{ needs.set-state.outputs.deploy_prod }}"
- run: echo "Clean cache - ${{ needs.set-state.outputs.clean_cache }}"
- run: echo "Repository org - ${{ github.event.repository.owner.login }}"
- run: echo "Repository name - ${{ github.event.repository.name }}"
- run: echo "Repository branch - ${{ needs.set-state.outputs.branch_short_ref }}"
- run: echo "Path prefix - ${{ needs.set-state.outputs.path_prefix }}"
- run: echo "Exclude subfolder - ${{ needs.set-state.outputs.exclude_subfolder }}"
pre-build-dev:
needs: [set-state]
runs-on: ubuntu-latest
if: needs.set-state.outputs.deploy_dev == 'true'
steps:
- name: check dev azure connection string
if: env.AIO_AZURE_DEV_CONNECTION_STRING == null
run: |
echo "::error::Please set the Azure Blob Storage connection string as AIO_AZURE_DEV_CONNECTION_STRING in Github Secrets"
exit 1
env:
AIO_AZURE_DEV_CONNECTION_STRING: ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}
build-dev:
defaults:
run:
shell: bash
needs: [set-state, pre-build-dev]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node v16 for Yarn v3
uses: actions/setup-node@v3
with:
node-version: "16.15.0" # Current LTS version
- name: Enable Corepack for Yarn v3
run: corepack enable
- name: Install Yarn v3
uses: borales/actions-yarn@v3
with:
cmd: set version stable
- name: Install Dependencies
uses: borales/actions-yarn@v3
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
with:
cmd: install
- name: Gatsby Cache
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }}
restore-keys: |
${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-
- name: Clean Cache
if: needs.set-state.outputs.clean_cache == 'true'
uses: borales/actions-yarn@v3
with:
cmd: clean
- name: Build site
uses: borales/actions-yarn@v3
with:
cmd: build
env:
PREFIX_PATHS: true # equivalent to --prefix-paths flag for 'gatsby build'
PATH_PREFIX: ${{ needs.set-state.outputs.path_prefix }}
GATSBY_ADOBE_LAUNCH_SRC: ${{ secrets.AIO_ADOBE_LAUNCH_DEV_SRC }}
GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS: ${{ secrets.AIO_REPORT_SUITE_DEV}}
GATSBY_ADOBE_ANALYTICS_ENV: "dev"
REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_OWNER: ${{ github.event.repository.owner.login }}
REPO_NAME: ${{ github.event.repository.name }}
REPO_BRANCH: ${{ needs.set-state.outputs.branch_short_ref }}
GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
GOOGLE_DOCS_TOKEN: ${{ secrets.GOOGLE_DOCS_TOKEN }}
GOOGLE_DOCS_FOLDER_ID: ${{ secrets.GOOGLE_DOCS_FOLDER_ID }}
GATSBY_IMS_SRC: ${{ secrets.AIO_IMS_DEV_SRC }}
GATSBY_IMS_CONFIG: ${{ secrets.AIO_IMS_DEV_CONFIG }}
GATSBY_ALGOLIA_APPLICATION_ID: ${{ secrets.AIO_ALGOLIA_APPLICATION_ID }}
GATSBY_ALGOLIA_SEARCH_API_KEY: ${{ secrets.AIO_ALGOLIA_SEARCH_API_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.AIO_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_API_KEY: ${{ secrets.AIO_ALGOLIA_API_KEY }}
GATSBY_ALGOLIA_INDEX_ALL_SRC: ${{ secrets.AIO_ALGOLIA_INDEX_ALL_SRC }}
GATSBY_ALGOLIA_SEARCH_INDEX: ${{ secrets.AIO_ALGOLIA_SEARCH_INDEX }}
GATSBY_ALGOLIA_INDEX_ENV_PREFIX: ${{ secrets.AIO_ALGOLIA_INDEX_ENV_PREFIX }}
GATSBY_FEDS_PRIVACY_ID: ${{ secrets.AIO_FEDS_PRIVACY_ID }}
GATSBY_SITE_DOMAIN_URL: https://developer-stage.adobe.com
- name: Deploy
uses: AdobeDocs/static-website-deploy@master
with:
enabled-static-website: "true"
source: "public"
target: ${{ needs.set-state.outputs.path_prefix }}
connection-string: ${{ secrets.AIO_AZURE_DEV_CONNECTION_STRING }}
remove-existing-files: "true"
exclude-subfolder: ${{ needs.set-state.outputs.exclude_subfolder }}
- name: Purge Fastly Cache
uses: AdobeDocs/gatsby-fastly-purge-action@master
with:
fastly-token: ${{ secrets.AIO_FASTLY_TOKEN }}
fastly-url: "${{ secrets.AIO_FASTLY_DEV_URL}}${{ needs.set-state.outputs.path_prefix }}"
pre-build-production:
needs: [set-state]
runs-on: ubuntu-latest
if: needs.set-state.outputs.deploy_prod == 'true'
steps:
- name: check prod azure connection string
if: env.AIO_AZURE_PROD_CONNECTION_STRING == null
run: |
echo "::error::Please set the Azure Blob Storage connection string as AIO_AZURE_PROD_CONNECTION_STRING in Github Secrets"
exit 1
env:
AIO_AZURE_PROD_CONNECTION_STRING: ${{ secrets.AIO_AZURE_PROD_CONNECTION_STRING }}
build-production:
defaults:
run:
shell: bash
needs: [set-state, pre-build-production]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node v16 for Yarn v3
uses: actions/setup-node@v3
with:
node-version: "16.15.0" # Current LTS version
- name: Enable Corepack for Yarn v3
run: corepack enable
- name: Install Yarn v3
uses: borales/actions-yarn@v3
with:
cmd: set version stable
- name: Install Dependencies
uses: borales/actions-yarn@v3
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
with:
cmd: install
- name: Gatsby Cache
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-${{ github.run_id }}
restore-keys: |
${{ needs.set-state.outputs.branch_short_ref }}-gatsby-cache-
- name: Clean Cache
if: needs.set-state.outputs.clean_cache == 'true'
uses: borales/actions-yarn@v3
with:
cmd: clean
- name: Build site
uses: borales/actions-yarn@v3
with:
cmd: build
env:
PREFIX_PATHS: true # equivalent to --prefix-paths flag for 'gatsby build'
PATH_PREFIX: ${{ needs.set-state.outputs.path_prefix }}
GATSBY_ADOBE_LAUNCH_SRC: ${{ secrets.AIO_ADOBE_LAUNCH_PROD_SRC }}
GATSBY_ADDITIONAL_ADOBE_ANALYTICS_ACCOUNTS: ${{ secrets.AIO_REPORT_SUITE_PROD }}
GATSBY_ADOBE_ANALYTICS_ENV: "production"
REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_OWNER: ${{ github.event.repository.owner.login }}
REPO_NAME: ${{ github.event.repository.name }}
REPO_BRANCH: ${{ needs.set-state.outputs.branch_short_ref }}
GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
GOOGLE_DOCS_TOKEN: ${{ secrets.GOOGLE_DOCS_TOKEN }}
GOOGLE_DOCS_FOLDER_ID: ${{ secrets.GOOGLE_DOCS_FOLDER_ID }}
GATSBY_IMS_SRC: ${{ secrets.AIO_IMS_PROD_SRC }}
GATSBY_IMS_CONFIG: ${{ secrets.AIO_IMS_PROD_CONFIG }}
GATSBY_ALGOLIA_APPLICATION_ID: ${{ secrets.AIO_ALGOLIA_APPLICATION_ID }}
GATSBY_ALGOLIA_SEARCH_API_KEY: ${{ secrets.AIO_ALGOLIA_SEARCH_API_KEY }}
GATSBY_ALGOLIA_APP_ID: ${{ secrets.AIO_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_API_KEY: ${{ secrets.AIO_ALGOLIA_API_KEY }}
ALGOLIA_WRITE_API_KEY: ${{ secrets.AIO_ALGOLIA_WRITE_API_KEY }}
ALGOLIA_INDEXATION_MODE: ${{ github.event.inputs.index-mode || 'index' }}
GATSBY_ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME || github.event.repository.name }}
GATSBY_ALGOLIA_INDEX_ALL_SRC: ${{ secrets.AIO_ALGOLIA_INDEX_ALL_SRC }}
GATSBY_ALGOLIA_SEARCH_INDEX: ${{ secrets.AIO_ALGOLIA_SEARCH_INDEX }}
GATSBY_ALGOLIA_INDEX_ENV_PREFIX: ${{ secrets.AIO_ALGOLIA_INDEX_ENV_PREFIX }}
GATSBY_FEDS_PRIVACY_ID: ${{ secrets.AIO_FEDS_PRIVACY_ID }}
GATSBY_SITE_DOMAIN_URL: https://developer.adobe.com
- name: Deploy
uses: AdobeDocs/static-website-deploy@master
with:
enabled-static-website: "true"
source: "public"
target: ${{ needs.set-state.outputs.path_prefix }}
connection-string: ${{ secrets.AIO_AZURE_PROD_CONNECTION_STRING }}
remove-existing-files: "true"
exclude-subfolder: ${{ needs.set-state.outputs.exclude_subfolder }}
- name: Purge Fastly Cache
uses: AdobeDocs/gatsby-fastly-purge-action@master
with:
fastly-token: ${{ secrets.AIO_FASTLY_TOKEN }}
fastly-url: "${{ secrets.AIO_FASTLY_PROD_URL }}${{ needs.set-state.outputs.path_prefix }}"