Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloud-function): implement Cloud Function + deploy to stage/prod #8366

Merged
merged 361 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
361 commits
Select commit Hold shift + click to select a range
f86fed5
chore(gcp/function): stick with /api/v1/stripe/plans
caugner Mar 23, 2023
58b57c5
ci(xyz-build): remove build temporarily
caugner Mar 23, 2023
6f7a97a
ci(xyz-build): use google-github-actions/deploy-cloud-functions
caugner Mar 23, 2023
f5871de
fixup! ci(xyz-build): use google-github-actions/deploy-cloud-functions
caugner Mar 23, 2023
4abfa6c
ci(xyz-build): allow concurrency
caugner Mar 23, 2023
60e4d8e
fix(gcp/function): set secret_environment_variables
caugner Mar 23, 2023
adc3e2e
fix(gcp/function): set entry_point
caugner Mar 23, 2023
9c81e2d
fixup! fix(gcp/function): set entry_point
caugner Mar 23, 2023
aeaedbf
fixup! fix(gcp/function): set secret_environment_variables
caugner Mar 23, 2023
d690137
Revert "ci(xyz-build): allow concurrency"
caugner Mar 23, 2023
1765d34
Revert "ci(xyz-build): remove build temporarily"
caugner Mar 23, 2023
c9c92ac
fix(gcp/function): apply req.originalUrl workaround to search-index.j…
caugner Mar 23, 2023
bb868a1
Merge branch 'main' into gcp
caugner Mar 23, 2023
4593a0a
chore(gcp/function): add X-Forwarded headers
caugner Mar 24, 2023
7d6663b
Merge branch 'main' into gcp
caugner Mar 27, 2023
2f149c8
fix(gcp/function): don't lowercase /static/
caugner Mar 27, 2023
65393db
fix(gcp/function): separate sitemaps + add content-encoding
caugner Mar 27, 2023
9021100
Merge branch 'main' into gcp
caugner Mar 29, 2023
5399c39
ci(xyz-build): use function name from vars context
caugner Mar 30, 2023
bc51fe4
chore(gcp/function): remove manual deployment
caugner Mar 30, 2023
2ca83db
ci(xyz-build): deploy into unique subfolder
caugner Mar 30, 2023
1474fde
fixup! ci(xyz-build): deploy into unique subfolder
caugner Mar 30, 2023
d9da292
fixup! fixup! ci(xyz-build): deploy into unique subfolder
caugner Mar 30, 2023
62168f1
chore(gcp): cleanup
caugner Mar 30, 2023
1b8f3df
ci(xyz-build): build all locales
caugner Mar 30, 2023
8621e41
ci(xyz-build): use more vars
caugner Mar 30, 2023
0839900
ci(xyz-build): use large runner
caugner Mar 30, 2023
cee095b
ci(xyz-build): build all locales in parallel
caugner Mar 30, 2023
78dcb35
ci(xyz-build): allow concurrency
caugner Mar 30, 2023
82ad81c
ci(xyz-build): omit tail header
caugner Mar 30, 2023
c0dcc66
ci(xyz-build): loop over locales + pids
caugner Mar 30, 2023
d158a75
Merge branch 'main' into gcp
caugner Mar 31, 2023
ba8da5f
ci(xyz-build): switch back to rsync with -c
caugner Mar 31, 2023
ec7a864
ci(xyz-build): copy static first
caugner Mar 31, 2023
483d483
ci(xyz-build): use runner with 4 cores
caugner Mar 31, 2023
04f652d
Merge branch 'main' into gcp
caugner Mar 31, 2023
aac8297
ci(xyz-build): rsync with -j html,json,txt
caugner Mar 31, 2023
4c4b5a2
ci(xyz-build): temporarily remove build/sync
caugner Mar 31, 2023
fb6d14e
ci(xyz-build): deploy v2 function via gcloud CLI
caugner Mar 31, 2023
c2117d4
Merge branch 'main' into gcp
caugner Apr 5, 2023
8cce715
ci(xyz-build): allow manual execution
caugner Apr 5, 2023
163e263
chore(gcp/function): use live-samples.mdn.mozilla.net
caugner Apr 5, 2023
fdd2706
feat(gcp/function): wrap with @sentry/serverless
caugner Apr 5, 2023
dde166e
ci(xyz-build): invalidate CDN once function is deployed
caugner Apr 5, 2023
22388a2
fixup! ci(xyz-build): invalidate CDN once function is deployed
caugner Apr 5, 2023
de05a08
fixup! feat(gcp/function): wrap with @sentry/serverless
caugner Apr 5, 2023
999fcac
fixup! feat(gcp/function): wrap with @sentry/serverless
caugner Apr 5, 2023
090abf3
Revert "ci(xyz-build): temporarily remove build/sync"
caugner Apr 5, 2023
59bdc74
ci(xyz-build): use live-samples subdomain
caugner Apr 5, 2023
a08ee67
fix(gcp/function): add X-Forwarded headers for Telemetry
caugner Apr 5, 2023
8a1186a
fix(gcp/function): do not change origin
caugner Apr 6, 2023
e99f0dc
fixup! fix(gcp/function): do not change origin
caugner Apr 6, 2023
e727152
chore(gcp/function): set timeout to 20s
caugner Apr 6, 2023
b0bb19f
chore(gcp/function): remove prepandPath: true (default value)
caugner Apr 6, 2023
f5384b4
fixup! chore(gcp/function): set timeout to 20s
caugner Apr 6, 2023
3d14d83
fixup! chore(gcp/function): remove prepandPath: true (default value)
caugner Apr 6, 2023
423b8c4
chore(gcp/function): stop redirecting leading slash
caugner Apr 6, 2023
48a10a0
Revert "chore(gcp/function): stop redirecting leading slash"
caugner Apr 6, 2023
67566fd
ci(xyz-build: reduce timeout to 30s
caugner Apr 6, 2023
955bcd8
ci(xyz-build): increase max-instances
caugner Apr 6, 2023
fb8b614
chore(gcp/function): set keep-alive on Glean proxy
caugner Apr 6, 2023
7ccacfe
ci(xyz-build): set min-instances = 1
caugner Apr 6, 2023
cc5bb48
fixup! Revert "ci(xyz-build): temporarily remove build/sync"
caugner Apr 6, 2023
f4ec605
ci(stage-build): deploy Cloud Function in multiple regions (#8540)
bkochendorfer Apr 6, 2023
0aad70c
Merge branch 'main' into gcp
caugner Apr 6, 2023
7326f00
ci(xyz-build): disable build
caugner Apr 6, 2023
f489b27
chore(gcp/function): forward telemetry to stage
caugner Apr 6, 2023
4b31285
Revert "chore(gcp/function): forward telemetry to stage"
caugner Apr 6, 2023
0ce2dd8
chore(gcp/function): set logLevel = debug
caugner Apr 6, 2023
e4f1dd3
chore(gcp/function): set secure = false
caugner Apr 6, 2023
e523516
chore(gcp/function): test with httpbin.org
caugner Apr 6, 2023
f1beaaa
fixup! chore(gcp/function): test with httpbin.org
caugner Apr 6, 2023
21b4507
chore(gcp/function): revert telemetry proxy
caugner Apr 6, 2023
a274279
chore(gcp/function): use http-proxy-middleware@beta
caugner Apr 6, 2023
d195e7a
chore(glean-context): set Context.testing = true if localhost
caugner Apr 6, 2023
7fb9ebd
Revert "ci(xyz-build): disable build"
caugner Apr 6, 2023
c107161
Revert "chore(glean-context): set Context.testing = true if localhost"
caugner Apr 6, 2023
ee2102e
Revert "Revert "ci(xyz-build): disable build""
caugner Apr 6, 2023
fe81cc4
chore(gcp/function): proxy telemetry with http-proxy
caugner Apr 6, 2023
a766bfe
fixup! chore(gcp/function): proxy telemetry with http-proxy
caugner Apr 6, 2023
c4c620b
chore(gcp/function): do not transform telemetry requests
caugner Apr 6, 2023
d1e5347
Revert "fixup! chore(gcp/function): proxy telemetry with http-proxy"
caugner Apr 6, 2023
f0f6e32
Revert "chore(gcp/function): proxy telemetry with http-proxy"
caugner Apr 6, 2023
db1b9dd
chore(gcp/function): downgrade to Node.js 16
caugner Apr 6, 2023
366c231
chore(gcp/function): downgrade to Node.js 14
caugner Apr 6, 2023
ff04701
chore(gcp/function): bump back to Node.js 18
caugner Apr 6, 2023
e59ebd5
chore(gcp/function): replace noCacheNoTransform with raw() middleware
caugner Apr 6, 2023
872d142
chore(gcp/function): pull express.raw() up
caugner Apr 6, 2023
283d286
feat(gcp/function): support local HTTPS
caugner Apr 7, 2023
e83b258
feat(gcp/function): use nodemon to auto-restart the app
caugner Apr 7, 2023
2dd3459
Revert "chore(gcp/function): use http-proxy-middleware@beta"
caugner Apr 7, 2023
dda902f
feat(gcp/function): add DEBUG_TELEMETRY option
caugner Apr 7, 2023
27245a9
chore(gcp/function): remove express.raw()
caugner Apr 7, 2023
667706d
fixup! feat(gcp/function): add DEBUG_TELEMETRY option
caugner Apr 7, 2023
7340364
fixup! feat(gcp/function): use nodemon to auto-restart the app
caugner Apr 7, 2023
6a49c46
chore(gcp/function): use compression() for telemetry
caugner Apr 7, 2023
1cd5729
chore(gcp/function): use fixRequestBody
caugner Apr 7, 2023
de56d8e
Revert "Revert "Revert "ci(xyz-build): disable build"""
caugner Apr 7, 2023
363c072
ci(xyz-build): skip steps via env vars
caugner Apr 7, 2023
a6f1348
fixup! ci(xyz-build): skip steps via env vars
caugner Apr 7, 2023
cb88022
feat(gcp/function): use @google-cloud/functions-framework
caugner Apr 7, 2023
c38f4d8
refactor(gcp/function): merge routers + add HTTPS proxy
caugner Apr 7, 2023
b55c50a
fixup! feat(gcp/function): use @google-cloud/functions-framework
caugner Apr 7, 2023
f4158dd
fixup! fixup! feat(gcp/function): use @google-cloud/functions-framework
caugner Apr 7, 2023
8441e22
fix(gcp/function): add DOM to lib
caugner Apr 7, 2023
3e28a02
fix(gcp/function): reference @yari-internal directly
caugner Apr 7, 2023
88db32b
fixup! fix(gcp/function): reference @yari-internal directly
caugner Apr 7, 2023
29c65bd
fixup! fixup! fixup! feat(gcp/function): use @google-cloud/functions-…
caugner Apr 7, 2023
7a29745
chore(gcp/function): generate redirects map on demand only
caugner Apr 7, 2023
3c8734b
feat(gcp/function): deploy functions concurrently in all regions
caugner Apr 7, 2023
de14caf
ci(xyz-build): redirect build into log files
caugner Apr 7, 2023
1993058
ci(xyz-build): print tail headers for function deploy
caugner Apr 7, 2023
5705425
Merge branch 'main' into gcp
caugner Apr 10, 2023
de61988
ci(stage-build): add SKIP conditions
caugner Apr 11, 2023
5425885
ci(stage-build): invalidate cdn cache in GCP
caugner Apr 11, 2023
f44fed5
ci(xyz-build): only run on function changes
caugner Apr 11, 2023
0b61f74
chore: empty commit
caugner Apr 11, 2023
ee6535c
fixup! ci(stage-build): invalidate cdn cache in GCP
caugner Apr 11, 2023
82d2404
ci(stage-build): GCP_LOAD_BALANCER_NAME is a secret
caugner Apr 11, 2023
28d0bf8
fixup! ci(stage-build): add SKIP conditions
caugner Apr 11, 2023
4856f5d
ci(stage-build): generate redirects map
caugner Apr 11, 2023
ed4fef1
ci(stage-build): deploy Function concurrently
caugner Apr 11, 2023
bc410d5
chore(workflows): prefix function build output
caugner Apr 11, 2023
66a6a03
ci(xyz-build): use rumba in GCP
caugner Apr 11, 2023
9025c86
Merge branch 'main' into gcp
caugner Apr 11, 2023
a338251
ci(stage-build): support skipping AWS
caugner Apr 11, 2023
3cc46dc
ci(workflows): prefix stderr as well
caugner Apr 11, 2023
91c70f4
ci(xyz-build): prefix build logs with sed
caugner Apr 11, 2023
33db686
ci(stage-build): add sentry env vars
caugner Apr 11, 2023
caa03f9
fix(gcp/function): use fixRequestBody for content/rumba as well
caugner Apr 11, 2023
c045879
refactor(gcp/function): rename withContentResponseHeaders
caugner Apr 11, 2023
ac2da1d
fix(gcp/function): set Cache-Control for content
caugner Apr 11, 2023
94ef0ea
fixup! chore(live-samples): use live-samples.mdn.mozilla/allizom.net …
caugner Apr 11, 2023
e255e1e
fixup! refactor(gcp/function): merge routers + add HTTPS proxy
caugner Apr 12, 2023
4fef41a
fix(gcp/function): make middlewares + handlers async
caugner Apr 12, 2023
9acb8fa
chore(gcp/function): set --concurrency=8
caugner Apr 12, 2023
15f1e7d
ci(stage-build): run on push to gcp
caugner Apr 12, 2023
a1e72e0
fix(gcp/function): use gcloud beta functions
caugner Apr 12, 2023
71d2bf5
fix(gcp/function): call gcloud beta with --quiet
caugner Apr 12, 2023
b088f73
ci(stage-build): use setup-gcloud with install_components instead of …
caugner Apr 12, 2023
5e7e76a
ci(stage-build): set --cpu=1 to allow concurrency
caugner Apr 12, 2023
411577e
ci(stage-build): set --memory=2GB
caugner Apr 12, 2023
a7575b6
ci(stage-build): avoid yarn install if we don't build
caugner Apr 12, 2023
864b985
chore(gcp/function): add 404 fallback
caugner Apr 12, 2023
e7eb856
ci(stage-build): increase max-instances from 100 to 1000
caugner Apr 12, 2023
fe88c2f
ci(stage-build): set --min-instances=100
caugner Apr 12, 2023
e7afa1c
ci(stage-build): reduce timeout to 30s
caugner Apr 12, 2023
0c3097a
ci(stage-build): increase concurrency from 8 to 16
caugner Apr 12, 2023
66b8f74
feat(gcp/function): add shortcut route for /
caugner Apr 12, 2023
27ef2a4
ci(xyz-build): test with 1 instance @ 16G / 4-cores
caugner Apr 12, 2023
a0f4f16
ci(xyz-build): avoid --quiet
caugner Apr 12, 2023
52304ea
ci(xyz-build): avoid yarn install if SKIP_BUILD
caugner Apr 12, 2023
933a7a8
ci(xyz-build): increase concurrency from 8 to 64
caugner Apr 12, 2023
50a98ee
fix(gcp/function): lowercase image pathnames in /docs
caugner Apr 12, 2023
796d59c
ci(workflows): lint
caugner Apr 12, 2023
834e562
ci(xyz-build): increase concurrency from 32 to 100
caugner Apr 12, 2023
85000b7
ci(stage-build): update scaling
caugner Apr 12, 2023
87d5b16
ci(xyz-build): increase max-instances from 1 to 100
caugner Apr 12, 2023
4bca8a5
chore(gcp): use 2GB function
caugner Apr 13, 2023
6c95668
ci(stage-build): set SENTRY_TRACES_SAMPLE_RATE
caugner Apr 13, 2023
b527f7d
ci(prod-build): replicate GCP changes from stage-build
caugner Apr 13, 2023
ffd0821
Merge branch 'main' into gcp
caugner Apr 13, 2023
290550d
fixup! ci(prod-build): replicate GCP changes from stage-build
caugner Apr 13, 2023
41c1953
fixup! ci(prod-build): replicate GCP changes from stage-build
caugner Apr 13, 2023
ea7ddb5
Update .github/workflows/prod-build.yml
caugner Apr 13, 2023
0df5c1c
fix(gcp/function): use Cloudfront-Viewer-Country header
caugner Apr 13, 2023
bd0bf45
chore(gcp/function): warn if headers already sent
caugner Apr 13, 2023
7f142ab
chore(gcp): copy static first, rsync -d, introduce GCP_BUCKET_NAME var
caugner Apr 13, 2023
506d89c
ci(xyz-build): extract invalidate job
caugner Apr 14, 2023
aa1e023
fixup! ci(xyz-build): extract invalidate job
caugner Apr 14, 2023
9b35f7e
migrage(pong): use pong internal lib in gcp
fiji-flo Apr 14, 2023
83a186b
chore(libs/pong): add TypeScript declarations
caugner Apr 14, 2023
4d36e1b
chore(libs/pong): improve TypeScript definitions
caugner Apr 14, 2023
c350dbb
chore(gcp/function): update package-lock.json
caugner Apr 14, 2023
a7ba030
chore(gcp/function): avoid userAgent being null
caugner Apr 14, 2023
6aedf7d
fix(gcp/function): use body, as body-parser already parses it
caugner Apr 14, 2023
4e37a16
Merge branch 'gcp-pong' into gcp
caugner Apr 14, 2023
6ed449d
ci(stage-build): extract invalidate job
caugner Apr 14, 2023
a39cc9c
chore(gcp/function): remove @adzerk/decision-sdk from deps
caugner Apr 14, 2023
90d0916
Revert "chore(gcp/function): remove @adzerk/decision-sdk from deps"
caugner Apr 14, 2023
7660a82
style: lint .github/workflows/*.yml
caugner Apr 14, 2023
a4a051f
ci(prod-build): extract invalidate job
caugner Apr 14, 2023
4a13e05
fixup! ci(prod-build): extract invalidate job
caugner Apr 14, 2023
9575c91
style(prettier): ignore /gcp/function/src/internal
caugner Apr 14, 2023
51a7b47
Update gcp/function/src/handlers/kevel.ts
fiji-flo Apr 17, 2023
dfdbbf1
Update libs/pong/coding.d.ts
caugner Apr 17, 2023
a7c755c
fix(gcp/function): check against null
caugner Apr 17, 2023
eea0d46
chore(libs/locale-utils): remove package-lock.json
caugner Apr 17, 2023
50b993c
fix(plans): call res.end() for fix timeout
fiji-flo Apr 17, 2023
876e978
Merge branch 'main' into gcp
caugner Apr 17, 2023
c38a3e0
ci(stage-build): remove on.push
caugner Apr 17, 2023
53b79fc
ci(xyz-build): build on push to main only
caugner Apr 17, 2023
4ac61b8
refactor(gcp/function): rename {redirects => build-redirects}
caugner Apr 17, 2023
3d0a92a
refactor(gcp/function): move {gcp/function => cloud-function}
caugner Apr 17, 2023
0d8799c
fixup! refactor(gcp/function): move {gcp/function => cloud-function}
caugner Apr 17, 2023
967ac5d
fixup! refactor(gcp/function): move {gcp/function => cloud-function}
caugner Apr 17, 2023
07e0d31
Merge branch 'main' into gcp
caugner Apr 17, 2023
dc594c8
fixup! refactor(gcp/function): move {gcp/function => cloud-function}
caugner Apr 17, 2023
93cb37d
fixup! refactor(gcp/function): move {gcp/function => cloud-function}
caugner Apr 17, 2023
42705d6
chore(cloud-function): reuse 404 buffer
caugner Apr 17, 2023
0d96c62
chore(cloud-function): remove unused file
caugner Apr 17, 2023
ba2fe23
chore(cloud-function): remove DEBUG_TELEMETRY
caugner Apr 17, 2023
bde5612
Revert "chore(cloud-function): remove unused file"
caugner Apr 17, 2023
da226cc
chore(cloud-function): remove unused constnat
caugner Apr 17, 2023
bdb49bd
feat(cloud-function): default to serving client/build
caugner Apr 17, 2023
e06c821
docs(cloud-function): update README
caugner Apr 17, 2023
ccface5
refactor(cloud-function): rename {plans => stripePlans}
caugner Apr 17, 2023
e3978bd
refactor(cloud-function): rename middlewares {fooBar => foo-bar}
caugner Apr 17, 2023
77fcb6b
refactor(cloud-function): rename handlers
caugner Apr 17, 2023
e5c7b61
refactor(cloud-function): return proxyContent handler from module
caugner Apr 17, 2023
7b50dbd
fixup! refactor(cloud-function): rename {plans => stripePlans}
caugner Apr 17, 2023
580328f
fixup! refactor(gcp/function): move {gcp/function => cloud-function}
caugner Apr 17, 2023
f00e08f
refactor(cloud-function): extract PROXY_TIMEOUT
caugner Apr 17, 2023
d60e40d
ci(xyz-build): add workflow_dispatch input
caugner Apr 17, 2023
524394f
ci(xyz-build): build on push to gcp
caugner Apr 17, 2023
0297a55
docs(cloud-function): format README
caugner Apr 17, 2023
af0423d
style(prettier): ignore compiled JS in cloud-function
caugner Apr 17, 2023
5092ee3
style(eslint): ignore compiled JS in cloud-function
caugner Apr 17, 2023
3869097
style: add trailing line
caugner Apr 17, 2023
b8dfbbb
refactor(cloud-function): rename LOCAL_{BUILD => CONTENT}
caugner Apr 17, 2023
8fe852d
refactor(cloud-function): remove SOURCE_LIVE_SAMPLES
caugner Apr 17, 2023
fd1a554
refactor(cloud-function): rename SOURCE_{RUMBA => API}
caugner Apr 17, 2023
ffb200b
ci(xyz-build): inline ORIGIN_{MAIN,LIVE_SAMPLES}
caugner Apr 17, 2023
b6f78b6
ci(xyz-build): make GCP_LOAD_BALANCER_NAME a secret
caugner Apr 17, 2023
47145ff
ci(xyz-build): shorten name
caugner Apr 17, 2023
0ed527a
ci(xyz-build): generate whatsdeployed
caugner Apr 17, 2023
57fed8b
chore(cloud-function): add .env-dist
caugner Apr 17, 2023
676243c
chore(cloud-function): default to stage API for convenience
caugner Apr 17, 2023
d20a923
docs(cloud-function): add quickstart to README
caugner Apr 17, 2023
530221c
ci: remove xyz-build
caugner Apr 17, 2023
5ab4693
fixup! chore(cloud-function): add .env-dist
caugner Apr 17, 2023
6abea05
fixup! ci: remove xyz-build
caugner Apr 17, 2023
37094d2
refactor(cloud-function): cleanup imports
caugner Apr 17, 2023
72d549c
workaround(content-proxy): 404 on slugs with dot
fiji-flo Apr 17, 2023
f55e878
chore(cloud-function): remove unused function
caugner Apr 17, 2023
53ee401
workaround(content-proxy): fix workaround
fiji-flo Apr 17, 2023
13092b5
fix(cloud-function): use path as slug, not full url with query
caugner Apr 17, 2023
4cad3cc
fix(cloud-function): reuse resolveIndexHtml for live samples
caugner Apr 18, 2023
c77996b
fixup! fix(cloud-function): reuse resolveIndexHtml for live samples
caugner Apr 18, 2023
ac8cd76
refactor(cloud-function): use array for api paths
caugner Apr 18, 2023
8e7a8d1
fix(cloud-function): use res.{send => sendStatus}
caugner Apr 18, 2023
0766f93
chore(cloud-function): serve /assets as is
caugner Apr 18, 2023
183425c
chore(cloud-function): serve root assets as is
caugner Apr 18, 2023
704447a
fix(cloud-function): add index.html to everything except assets
caugner Apr 18, 2023
a609725
fix(cloud-function): parse/format url in resolveIndexHTML
caugner Apr 18, 2023
2f44e68
fix(cloud-function): touch req.url only if url has pathname
caugner Apr 18, 2023
ef8ee2d
chore(cloud-function): remove compression
caugner Apr 18, 2023
f1e4a7d
refactor(cloud-function): use res.{status => sendStatus}
caugner Apr 18, 2023
69e897d
fix(cloud-function): do not apply 404 fallback to live-samples
caugner Apr 18, 2023
7d1f559
refactor(cloud-function): extract isLiveSampleURL()
caugner Apr 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ libs/
client/public/service-worker.js
client/public/
client/src/document/*.js
cloud-function/src/internal/
cloud-function/**/*.js
filecheck/*.js
mdn/content/
tool/*.js
135 changes: 117 additions & 18 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ on:
WIP_PROJECT_ID:
required: true

permissions:
contents: read
id-token: write

jobs:
build:
environment: prod
permissions:
contents: read
id-token: write

runs-on: ubuntu-latest-4core

# Only run the scheduled workflows on the main repo.
Expand All @@ -65,6 +65,7 @@ jobs:
- uses: actions/checkout@v3

- uses: actions/checkout@v3
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
with:
repository: mdn/content
path: mdn/content
Expand All @@ -87,40 +88,48 @@ jobs:
echo "DEPLOYER_LOG_EACH_SUCCESSFUL_UPLOAD=${{ github.event.inputs.log_each_successful_upload || env.DEFAULT_LOG_EACH_SUCCESSFUL_UPLOAD }}" >> $GITHUB_ENV

- uses: actions/checkout@v3
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
with:
repository: mdn/translated-content
path: mdn/translated-content
# See matching warning for mdn/content checkout step
fetch-depth: 0

- uses: actions/checkout@v3
if: ${{ ! vars.SKIP_BUILD }}
with:
repository: mdn/mdn-contributor-spotlight
path: mdn/mdn-contributor-spotlight

- name: Setup Node.js environment
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: Install all yarn packages
if: ${{ ! vars.SKIP_BUILD }}
run: yarn --frozen-lockfile

- name: Install Python
if: ${{ ! vars.SKIP_BUILD }}
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Python poetry
if: ${{ ! vars.SKIP_BUILD }}
uses: snok/install-poetry@v1

- name: Install deployer
if: ${{ ! vars.SKIP_BUILD }}
run: |
cd deployer
poetry install

- name: Display Python & Poetry version
if: ${{ ! vars.SKIP_BUILD }}
run: |
python --version
poetry --version
Expand All @@ -135,6 +144,7 @@ jobs:
run: cat /proc/cpuinfo

- name: Build everything
if: ${{ ! vars.SKIP_BUILD }}
env:
# Remember, the mdn/content repo got cloned into `pwd` into a
# sub-folder called "mdn/content"
Expand Down Expand Up @@ -233,10 +243,11 @@ jobs:

# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
yarn tool whatsdeployed $CONTENT_ROOT --output client/build/_whatsdeployed/content.json
yarn tool whatsdeployed $CONTENT_ROOT --output client/build/_whatsdeployed/content.json
yarn tool whatsdeployed $CONTENT_TRANSLATED_ROOT --output client/build/_whatsdeployed/translated-content.json

- name: Deploy with deployer
if: ${{ ! (vars.SKIP_BUILD || vars.SKIP_AWS) }}
env:
GITHUB_SHA: ${{ env.GITHUB_SHA }}
GITHUB_RUN_ID: ${{ env.GITHUB_RUN_ID }}
Expand Down Expand Up @@ -273,32 +284,85 @@ jobs:
poetry run deployer update-lambda-functions ./aws-lambda
poetry run deployer search-index ../client/build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
- name: Authenticate with GCP
if: ${{ ! vars.SKIP_BUILD }}
uses: google-github-actions/auth@v1
with:
aws-access-key-id: ${{ secrets.DEPLOYER_PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYER_PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
token_format: access_token
service_account: deploy-prod-content@${{ secrets.GCP_PROJECT_NAME }}.iam.gserviceaccount.com
caugner marked this conversation as resolved.
Show resolved Hide resolved
workload_identity_provider: projects/${{ secrets.WIP_PROJECT_ID }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions

- name: Invalidate CDN
env:
DISTRIBUTION: E2ZY2DGUN70EMI
PATHS: /*
run: aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" --paths "$PATHS"
- name: Setup gcloud
if: ${{ ! vars.SKIP_BUILD }}
uses: google-github-actions/setup-gcloud@v1

- name: Sync Yari Content
if: ${{ ! vars.SKIP_BUILD }}
run: |-
gsutil -q -m -h "Cache-Control: public, max-age=86400" cp -r client/build/static gs://${{ vars.GCP_BUCKET_NAME }}/main/static
gsutil -q -m -h "Cache-Control: public, max-age=86400" rsync -cdrj html,json,txt client/build gs://${{ vars.GCP_BUCKET_NAME }}/main

- name: Authenticate with GCP
if: ${{ ! vars.SKIP_FUNCTION }}
uses: google-github-actions/auth@v1
with:
token_format: access_token
service_account: deploy-prod-content@${{ secrets.GCP_PROJECT_NAME }}.iam.gserviceaccount.com
service_account: deploy-prod-prod-mdn-ingress@${{ secrets.GCP_PROJECT_NAME }}.iam.gserviceaccount.com
workload_identity_provider: projects/${{ secrets.WIP_PROJECT_ID }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions

- name: Setup gcloud
if: ${{ ! vars.SKIP_FUNCTION }}
uses: google-github-actions/setup-gcloud@v1
with:
install_components: "beta"

- name: Sync Yari Content
- name: Generate redirects map
if: ${{ ! vars.SKIP_FUNCTION }}
working-directory: cloud-function
env:
CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files
CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/mdn/translated-content/files
run: |-
gsutil -m -h "Cache-Control:public, max-age=86400" rsync -crj html,json,txt client/build gs://content-prod-mdn/main
npm ci
npm run build-redirects

- name: Deploy Function
if: ${{ ! vars.SKIP_FUNCTION }}
run: |-
for region in europe-west1 us-west1 asia-east1; do
gcloud beta functions deploy mdn-prod-prod-$region \
--gen2 \
--runtime=nodejs18 \
--region=$region \
--source=cloud-function \
--trigger-http \
--allow-unauthenticated \
--entry-point=mdnHandler \
--concurrency=100 \
--min-instances=10 \
--max-instances=1000 \
--memory=2GB \
--timeout=30s \
--set-env-vars="ORIGIN_MAIN=developer.mozilla.org" \
--set-env-vars="ORIGIN_LIVE_SAMPLES=live-samples.mdn.mozilla.net" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
--set-env-vars="SOURCE_API=https://api.developer.mozilla.org/" \
--set-env-vars="SENTRY_DSN=${{ secrets.SENTRY_DSN_CLOUD_FUNCTION }}" \
--set-env-vars="SENTRY_ENVIRONMENT=prod" \
--set-env-vars="SENTRY_TRACES_SAMPLE_RATE=${{ vars.SENTRY_TRACES_SAMPLE_RATE }}" \
--set-env-vars="SENTRY_RELEASE=${{ github.sha }}" \
--set-secrets="KEVEL_SITE_ID=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/prod-kevel-site-id/versions/latest" \
--set-secrets="KEVEL_NETWORK_ID=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/prod-kevel-network-id/versions/latest" \
--set-secrets="SIGN_SECRET=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/prod-sign-secret/versions/latest" \
--set-secrets="CARBON_ZONE_KEY=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/prod-carbon-zone-key/versions/latest" \
--set-secrets="CARBON_FALLBACK_ENABLED=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/prod-fallback-enabled/versions/latest" \
caugner marked this conversation as resolved.
Show resolved Hide resolved
2>&1 | sed "s/^/[$region] /" &
pids+=($!)
done

for pid in "${pids[@]}"; do
wait $pid
done

- name: Slack Notification
if: failure()
Expand All @@ -311,3 +375,38 @@ jobs:
SLACK_MESSAGE: "Build failed :collision:"
SLACK_FOOTER: "Powered by prod-build.yml"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

invalidate:
environment: prod
needs: build
if: ${{ ! vars.SKIP_INVALIDATE }}
runs-on: ubuntu-latest

steps:
- name: Configure AWS Credentials
if: ${{ ! vars.SKIP_AWS }}
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.DEPLOYER_PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYER_PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Invalidate AWS CloudFront CDN
if: ${{ ! vars.SKIP_AWS }}
env:
DISTRIBUTION: E2ZY2DGUN70EMI
PATHS: /*
run: aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" --paths "$PATHS"

- name: Authenticate with GCP
uses: google-github-actions/auth@v1
with:
token_format: access_token
service_account: deploy-prod-prod-mdn-ingress@${{ secrets.GCP_PROJECT_NAME }}.iam.gserviceaccount.com
workload_identity_provider: projects/${{ secrets.WIP_PROJECT_ID }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions

- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v1

- name: Invalidate Google Cloud CDN
run: gcloud compute url-maps invalidate-cdn-cache ${{ secrets.GCP_LOAD_BALANCER_NAME }} --path "/*"
Loading