Skip to content

Commit fd959c9

Browse files
committed
ci(xyz-build): sync with stage-build
1 parent bd1b6ad commit fd959c9

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

Diff for: .github/workflows/xyz-build.yml

+39-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: XYZ Build
22

3+
env:
4+
DEFAULT_NOTES: ""
5+
36
on:
47
push:
58
branches:
@@ -9,6 +12,11 @@ on:
912
- cloud-function/**
1013

1114
workflow_dispatch:
15+
inputs:
16+
notes:
17+
description: "Notes"
18+
required: false
19+
default: ${DEFAULT_NOTES}
1220

1321
workflow_call:
1422
secrets:
@@ -38,6 +46,7 @@ jobs:
3846
- uses: actions/checkout@v3
3947

4048
- uses: actions/checkout@v3
49+
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
4150
with:
4251
repository: mdn/content
4352
path: mdn/content
@@ -48,18 +57,28 @@ jobs:
4857
fetch-depth: 0
4958

5059
- uses: actions/checkout@v3
60+
if: ${{ ! vars.SKIP_BUILD }}
61+
with:
62+
repository: mdn/mdn-studio
63+
path: mdn/mdn-studio
64+
token: ${{ secrets.MDN_STUDIO_PAT }}
65+
66+
- uses: actions/checkout@v3
67+
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
5168
with:
5269
repository: mdn/translated-content
5370
path: mdn/translated-content
5471
# See matching warning for mdn/content checkout step
5572
fetch-depth: 0
5673

5774
- uses: actions/checkout@v3
75+
if: ${{ ! vars.SKIP_BUILD }}
5876
with:
5977
repository: mdn/mdn-contributor-spotlight
6078
path: mdn/mdn-contributor-spotlight
6179

6280
- name: Setup Node.js environment
81+
if: ${{ ! vars.SKIP_BUILD || ! vars.SKIP_FUNCTION }}
6382
uses: actions/setup-node@v3
6483
with:
6584
node-version: 18
@@ -80,6 +99,8 @@ jobs:
8099
CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files
81100
CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/mdn/translated-content/files
82101
CONTRIBUTOR_SPOTLIGHT_ROOT: ${{ github.workspace }}/mdn/mdn-contributor-spotlight/contributors
102+
BLOG_ROOT: ${{ github.workspace }}/mdn/mdn-studio/content/posts
103+
BASE_URL: "https://developer.allizom.xyz"
83104

84105
# The default for this environment variable is geared for writers
85106
# (aka. local development). Usually defaults are supposed to be for
@@ -97,7 +118,7 @@ jobs:
97118
# If it's used on other domains (e.g. stage or dev builds), it's OK
98119
# because ultimately Google Analytics will filter it out since the
99120
# origin domain isn't what that account expects.
100-
#BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-36116321-5
121+
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-36116321-5
101122

102123
# This enables the Plus call-to-action banner and the Plus landing page
103124
REACT_APP_ENABLE_PLUS: true
@@ -117,11 +138,7 @@ jobs:
117138
REACT_APP_MDN_PLUS_10M_PLAN: price_1K6X7gKb9q6OnNsLi44HdLcC
118139
REACT_APP_MDN_PLUS_10Y_PLAN: price_1K6X8VKb9q6OnNsLFlUcEiu4
119140

120-
# Surveys.
121-
REACT_APP_SURVEY_START_CONTENT_DISCOVERY_2023: 0 # stage
122-
REACT_APP_SURVEY_END_CONTENT_DISCOVERY_2023: 1677672000000 # (new Date("2023-03-01 12:00:00Z")).getTime()
123-
REACT_APP_SURVEY_RATE_FROM_CONTENT_DISCOVERY_2023: 0.0
124-
REACT_APP_SURVEY_RATE_TILL_CONTENT_DISCOVERY_2023: 0.05 # 5%
141+
# No surveys.
125142

126143
# Telemetry.
127144
REACT_APP_GLEAN_CHANNEL: xyz
@@ -138,6 +155,7 @@ jobs:
138155
# Info about which CONTENT_* environment variables were set and to what.
139156
echo "CONTENT_ROOT=$CONTENT_ROOT"
140157
echo "CONTENT_TRANSLATED_ROOT=$CONTENT_TRANSLATED_ROOT"
158+
echo "BLOG_ROOT=$BLOG_ROOT"
141159
# Build the ServiceWorker first
142160
yarn build:sw
143161
yarn build:prepare
@@ -149,6 +167,8 @@ jobs:
149167
150168
yarn tool sync-translated-content
151169
170+
# Build using one process per locale.
171+
# Note: We have 4 cores, but 9 processes is a reasonable number.
152172
for locale in en-us es fr ja ko pt-br ru zh-cn zh-tw; do
153173
yarn build --locale $locale 2>&1 | sed "s/^/[$locale] /" &
154174
pids+=($!)
@@ -163,6 +183,9 @@ jobs:
163183
# Generate sitemap index file
164184
yarn build --sitemap-index
165185
186+
# Build the blog
187+
yarn build:blog
188+
166189
# Generate whatsdeployed files.
167190
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
168191
yarn tool whatsdeployed $CONTENT_ROOT --output client/build/_whatsdeployed/content.json
@@ -183,8 +206,8 @@ jobs:
183206
- name: Sync build with GCS bucket
184207
if: ${{ ! vars.SKIP_BUILD }}
185208
run: |
186-
gsutil -q -m cp -r client/build/static gs://${{ vars.GCP_BUCKET_NAME }}/$BUCKET_PATH/static
187-
gsutil -q -m rsync -cdrj html,json,txt client/build gs://${{ vars.GCP_BUCKET_NAME }}/$BUCKET_PATH
209+
gsutil -q -m -h "Cache-Control: public, max-age=86400" cp -r client/build/static gs://${{ vars.GCP_BUCKET_NAME }}/$BUCKET_PATH/
210+
gsutil -q -m -h "Cache-Control: public, max-age=86400" rsync -cdrj html,json,txt -y "^static/" client/build gs://${{ vars.GCP_BUCKET_NAME }}/$BUCKET_PATH
188211
189212
- name: Generate redirects map
190213
if: ${{ ! vars.SKIP_FUNCTION }}
@@ -208,9 +231,9 @@ jobs:
208231
--trigger-http \
209232
--allow-unauthenticated \
210233
--entry-point=mdnHandler \
234+
--concurrency=100 \
211235
--min-instances=1 \
212236
--max-instances=100 \
213-
--concurrency=100 \
214237
--memory=2GB \
215238
--timeout=30s \
216239
--set-env-vars="ORIGIN_MAIN=developer.allizom.xyz" \
@@ -221,11 +244,11 @@ jobs:
221244
--set-env-vars="SENTRY_ENVIRONMENT=xyz" \
222245
--set-env-vars="SENTRY_TRACES_SAMPLE_RATE=${{ vars.SENTRY_TRACES_SAMPLE_RATE }}" \
223246
--set-env-vars="SENTRY_RELEASE=${{ github.sha }}" \
224-
--set-secrets="KEVEL_SITE_ID=projects/${{ secrets.WIP_PROJECT_ID }}/secrets/stage-kevel-site-id/versions/latest" \
225-
--set-secrets="KEVEL_NETWORK_ID=projects/${{ secrets.WIP_PROJECT_ID }}/secrets/stage-kevel-network-id/versions/latest" \
226-
--set-secrets="SIGN_SECRET=projects/${{ secrets.WIP_PROJECT_ID }}/secrets/stage-sign-secret/versions/latest" \
227-
--set-secrets="CARBON_ZONE_KEY=projects/${{ secrets.WIP_PROJECT_ID }}/secrets/stage-carbon-zone-key/versions/latest" \
228-
--set-secrets="CARBON_FALLBACK_ENABLED=projects/${{ secrets.WIP_PROJECT_ID }}/secrets/stage-fallback-enabled/versions/latest" \
247+
--set-secrets="KEVEL_SITE_ID=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-kevel-site-id/versions/latest" \
248+
--set-secrets="KEVEL_NETWORK_ID=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-kevel-network-id/versions/latest" \
249+
--set-secrets="SIGN_SECRET=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-sign-secret/versions/latest" \
250+
--set-secrets="CARBON_ZONE_KEY=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-carbon-zone-key/versions/latest" \
251+
--set-secrets="CARBON_FALLBACK_ENABLED=projects/${{ secrets.GCP_PROJECT_NAME }}/secrets/stage-fallback-enabled/versions/latest" \
229252
2>&1 | sed "s/^/[$region] /" &
230253
pids+=($!)
231254
done
@@ -234,23 +257,6 @@ jobs:
234257
wait $pid
235258
done
236259
237-
invalidate:
238-
environment: xyz
239-
needs: build
240-
if: ${{ ! vars.SKIP_INVALIDATE }}
241-
runs-on: ubuntu-latest
242-
243-
steps:
244-
- name: Authenticate with GCP
245-
uses: google-github-actions/auth@v0
246-
with:
247-
token_format: access_token
248-
service_account: deploy-xyz-yari@${{ secrets.GCP_PROJECT_NAME }}.iam.gserviceaccount.com
249-
workload_identity_provider: projects/${{ secrets.WIP_PROJECT_ID }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions
250-
251-
- name: Setup gcloud
252-
uses: google-github-actions/setup-gcloud@v1
253-
254260
- name: Invalidate CDN
255-
run: |-
256-
gcloud compute url-maps invalidate-cdn-cache ${{ secrets.GCP_LOAD_BALANCER_NAME }} --path "/*"
261+
if: ${{ ! vars.SKIP_INVALIDATE }}
262+
run: gcloud compute url-maps invalidate-cdn-cache ${{ secrets.GCP_LOAD_BALANCER_NAME }} --path "/*" --async

0 commit comments

Comments
 (0)