-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (179 loc) · 8.28 KB
/
dev-build.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
name: Dev Build
# NOTE! This is the *DEV* workflow.
# Keep in mind that much of the configuration is repeated in `prod-build.yml`
# and `stage-build.yml`
#
# For a complete picture of all environments, see:
#
# https://docs.google.com/spreadsheets/d/1VnnEl-iTtKYmlyN02FiEXygxZCgE4o_ZO8wSleebne4/edit?usp=sharing
#
# NOTE! Unlike prod and stage, this work only works on manual dispatch
on:
workflow_dispatch:
inputs:
notes:
description: "Notes"
required: false
default: ""
archived_content:
description: "Build archived content"
required: false
default: "false"
# This is very useful when combined with the "Use workflow from"
# feature that is built into the "Run workflow" button on
# https://github.com/mdn/yari/actions?query=workflow%3A%22Production+Build%22
# If you override the deployment prefix to something like the name
# of the branch, you can deploy that entire branch to its own prefix
# in S3 which means that it can be fully hosted as its own site.
deployment_prefix:
description: "Deployment prefix"
required: false
default: "main"
log_each_successful_upload:
description: "Deployer logs each success"
required: false
default: "false"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
repository: mdn/content
path: mdn/content
# Yes, this means fetch EVERY COMMIT EVER.
# It's probably not sustainable in the far future (e.g. past 2021)
# but for now it's good enough. We'll need all the history
# so we can figure out each document's last-modified date.
fetch-depth: 0
- uses: actions/[email protected]
if: "contains(github.event.inputs.archived_content, 'true')"
with:
repository: mdn/archived-content
path: mdn/archived-content
- uses: actions/[email protected]
with:
repository: mdn/translated-content
path: mdn/translated-content
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: "16"
- name: Cache node_modules
uses: actions/[email protected]
id: cached-node_modules
with:
path: |
node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install all yarn packages
if: steps.cached-node_modules.outputs.cache-hit != 'true'
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
run: yarn --frozen-lockfile
- name: Install Python
uses: actions/[email protected]
with:
python-version: "3.8"
- name: Install Python poetry
uses: snok/[email protected]
- name: Install deployer
run: |
cd deployer
poetry install
- name: Display Python & Poetry version
run: |
python --version
poetry --version
- name: Print information about build
run: |
echo "notes: ${{ github.event.inputs.notes }}"
echo "archived_content: ${{ github.event.inputs.archived_content }}"
echo "log_each_successful_upload: ${{ github.event.inputs.log_each_successful_upload }}"
echo "deployment_prefix: ${{ github.event.inputs.deployment_prefix }}"
- name: Build everything
env:
# Remember, the mdn/content repo got cloned into `pwd` into a
# sub-folder called "mdn/content"
CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files
CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/mdn/translated-content/files
# This basically means that all live-sample iframes run on the same
# host as the page that includes the iframe. Not great security but the
# context is that this is Dev and it's not connected to a real backend.
BUILD_LIVE_SAMPLES_BASE_URL: ""
# Now is not the time to worry about flaws.
BUILD_FLAW_LEVELS: "*:ignore"
# Uncomment when hacking on this workflow. It means the `yarn build`
# finishes much sooner, which can be helpful debugging the other stuff
# the workflow needs to do.
# BUILD_FOLDERSEARCH: web/html
# This just makes sure the Google Analytics script gets used even if
# it goes nowhere.
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-00000000-0
# Same with the Speedcurve LUX
BUILD_SPEEDCURVE_LUX_ID: 000000000
# Make sure every built page always has
# '<meta name="robots" content="noindex, ">' nomatter what
# kind of document it is.
BUILD_ALWAYS_NO_ROBOTS: true
run: |
if [ ${{ github.event.inputs.archived_content }} == "true" ]; then
echo "Will build mdn/archived-content too"
export CONTENT_ARCHIVED_ROOT=${{ github.workspace }}/mdn/archived-content/files
else
echo "Will NOT build mdn/archived-content too"
fi
# Info about which CONTENT_* environment variables were set and to what.
echo "CONTENT_ROOT=$CONTENT_ROOT"
echo "CONTENT_ARCHIVED_ROOT=$CONTENT_ARCHIVED_ROOT"
echo "CONTENT_TRANSLATED_ROOT=$CONTENT_TRANSLATED_ROOT"
yarn prepare-build
yarn tool sync-translated-content
yarn build
# TODO: When the deployer is available this is where we
# would upload the whole content of client/build
du -sh client/build
- name: Deploy with deployer
env:
# Set the CONTENT_ROOT first
CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files
CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/mdn/translated-content/files
DEPLOYER_BUCKET_NAME: mdn-content-dev
DEPLOYER_BUCKET_PREFIX: ${{ github.event.inputs.deployment_prefix }}
DEPLOYER_LOG_EACH_SUCCESSFUL_UPLOAD: ${{ github.event.inputs.log_each_successful_upload }}
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_SECRET_ACCESS_KEY }}
DEPLOYER_ELASTICSEARCH_URL: ${{ secrets.DEPLOYER_DEV_ELASTICSEARCH_URL }}
run: |
if [ ${{ github.event.inputs.archived_content }} == "true" ]; then
echo "Will build mdn/archived-content too"
export CONTENT_ARCHIVED_ROOT=${{ github.workspace }}/mdn/archived-content/files
else
echo "Will NOT build mdn/archived-content too"
fi
if [ ${{ github.event.inputs.translated_content }} == "true" ]; then
echo "Will build mdn/translated-content too"
export CONTENT_TRANSLATED_ROOT=${{ github.workspace }}/mdn/translated-content/files
else
echo "Will NOT build mdn/translated-content too"
fi
# Info about which CONTENT_* environment variables were set and to what.
echo "CONTENT_ROOT=$CONTENT_ROOT"
echo "CONTENT_ARCHIVED_ROOT=$CONTENT_ARCHIVED_ROOT"
echo "CONTENT_TRANSLATED_ROOT=$CONTENT_TRANSLATED_ROOT"
cd deployer
poetry run deployer whatsdeployed --output ../client/build/_whatsdeployed/code.json
poetry run deployer whatsdeployed --output ../client/build/_whatsdeployed/content.json $CONTENT_ROOT
poetry run deployer whatsdeployed --output ../client/build/_whatsdeployed/translated-content.json $CONTENT_TRANSLATED_ROOT
# XXX would be nice to validate here that $DEPLOYER_BUCKET_PREFIX is truthy
echo "DEPLOYER_BUCKET_PREFIX=$DEPLOYER_BUCKET_PREFIX"
# Prune again once https://github.com/mdn/yari/issues/3323 is resolved.
# poetry run deployer upload --prune --archived-files ../content/archived.txt ../client/build
poetry run deployer upload ../client/build
poetry run deployer update-lambda-functions ./aws-lambda
# TODO
# Execute command to tell the Dev CloudFront distribution to use the
# latest and greatest *version* of the updated lambda functions.
# (Or, make it an optional flag to the `update-lambda-functions` command)
poetry run deployer search-index ../client/build