Repository navigation
577 lines (514 loc) · 25 KB
/
Copy pathbuild.yml
File metadata and controls
577 lines (514 loc) · 25 KB
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
name: Build
on:
push:
branches:
- 'trunk'
- 'prerelease'
# The `**/*/` works around the fact that GitHub considers a leading `**/` as meaning "zero or more path components" where we want "one or more".
- '**/*/branch-**'
pull_request:
concurrency:
# Cancel concurrent jobs on pull_request but not push, by including the run_id in the concurrency group for the latter.
group: build-${{ case( github.event_name == 'push', github.run_id, 'pr' ) }}-${{ github.ref }}
cancel-in-progress: true
permissions:
# actions/checkout, actions/upload-artifact, actions/download-artifact
contents: read
env:
COMPOSER_ROOT_VERSION: "dev-trunk"
# This string is used as a unique identifier of test reminder comments on PRs.
TEST_COMMENT_INDICATOR: "<!-- wpcom-reminder-comment -->"
# Trade some archive size for much faster compression.
XZ_OPT: -3 -T0
jobs:
# Runs alongside the builds so the pending reminder appears early. merge_artifacts adds the testing instructions.
reminder_comment:
name: Check WordPress.com test reminder
runs-on: ubuntu-latest
timeout-minutes: 5 # 2026-04-07: Should take about a minute.
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
permissions:
# actions/checkout
contents: read
# Comment posting
pull-requests: write
outputs:
comment_id: ${{ steps.check-test-reminder-comment.outputs.result }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
# list-changed-projects.sh needs the merge base, but it doesn't have to be checked out.
- name: Deepen to merge base
uses: $/.github/actions/deepen-to-merge-base
with:
checkout: false
- name: Setup tools
uses: $/.github/actions/tool-setup
with:
php: false
- name: Pnpm install
run: pnpm install
- name: Detect changed projects
id: changed
run: echo "projects=$(EXTRA=build .github/files/list-changed-projects.sh)" >> "$GITHUB_OUTPUT"
- name: Check if a WordPress.com test reminder comment is needed.
id: check-test-reminder-comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
env:
CHANGED: ${{ steps.changed.outputs.projects }}
with:
script: |
const { checkTestPendingComment } = require('.github/files/build-reminder-comment/check-test-reminder-comment.js')
const data = await checkTestPendingComment( github, context, core );
return data;
# Trunk pushes build everything, split into 'wpcom' and 'nonwpcom' jobs so the 'wpcom' job can push certain plugins to mirrors. Everything else gets the single 'all' job.
# Have to manually matrix with yaml anchors, because `update_wpcom_mirrors` needs to depend on only `build_wpcom` and that's not possible with normal matrixing.
build_all:
name: Build all projects
runs-on: ubuntu-latest
if: ${{ ! ( github.event_name == 'push' && github.ref == 'refs/heads/trunk' ) }}
env:
FILENAME: partial-build-all.tar.xz
# Hard-code a specific directory to avoid paths in vendor/composer/installed.json changing every build.
BUILD_BASE: /tmp/jetpack-build
timeout-minutes: 30 # 2026-08-18: Successful runs take ~18 minutes.
steps: &build_steps
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
# For pull requests, list-changed-projects.sh needs the merge base.
# But it doesn't have to be checked out.
- name: Deepen to merge base
if: github.event_name == 'pull_request'
uses: $/.github/actions/deepen-to-merge-base
with:
checkout: false
- name: Setup tools
uses: $/.github/actions/tool-setup
- name: Pnpm install
run: pnpm install
- name: Detect changed projects
shell: bash
run: |
if [[ "$GITHUB_JOB" == build_all ]]; then
CHANGED="$(EXTRA=build .github/files/list-changed-projects.sh)"
else
pnpm jetpack dependencies list --extra=build --ignore-root --add-dependencies plugins/jetpack plugins/mu-wpcom-plugin | sort > "$RUNNER_TEMP/wpcom.txt"
if [[ "$GITHUB_JOB" == build_nonwpcom ]]; then
pnpm jetpack dependencies list --extra=build --ignore-root | sort > "$RUNNER_TEMP/all.txt"
LIST=$( comm -23 "$RUNNER_TEMP/all.txt" "$RUNNER_TEMP/wpcom.txt" )
else
LIST=$(< "$RUNNER_TEMP/wpcom.txt" )
fi
CHANGED=$( jq -ncR 'reduce inputs as $i ({}; .[$i] |= true)' <<<"$LIST" )
fi
echo "CHANGED=${CHANGED}" >> "$GITHUB_ENV"
# We need the tree (but not the blob) for packages that will have -alpha version numbers so the timestamp appending works right.
# We also need the tree for js-packages/social-logos/src/svg so the font build will work right.
- name: Deepen tree for packages
run: |
mapfile -t PROJECTS < <(jq -r 'to_entries[] | select( .value ) | .key' <<<"$CHANGED")
if [[ ${#PROJECTS[@]} -gt 0 ]]; then
depth=$( git rev-list --count --first-parent HEAD )
[[ "$depth" -lt 1000 ]] && depth=1000
BASE=$PWD
REF=$(git rev-parse HEAD)
for SLUG in $(pnpm jetpack dependencies list --add-dependencies --extra="build" --ignore-root "${PROJECTS[@]}"); do
cd "$BASE/projects/$SLUG/"
if [[ "$SLUG" == packages/* ]]; then
SUBDIR=.
# Only deepen if it'll be a -alpha, i.e. it has changelog entries
CHANGES_DIR="$(jq -r '.extra.changelogger["changes-dir"] // "changelog"' composer.json)"
[[ -d "$CHANGES_DIR" && -n "$(ls -- "$CHANGES_DIR")" ]] || continue
elif [[ "$SLUG" == js-packages/social-logos ]]; then
SUBDIR=./src/svg
else
continue
fi
echo "Checking depth for $SLUG"
while git log --format='%h, %D,' -1 "$SUBDIR" | grep ', grafted,'; do
depth=$((depth * 2))
echo "::group::Deepen to $depth"
echo "/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=$depth --filter=blob:none origin $REF"
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=$depth --filter=blob:none origin "$REF"
echo "::endgroup::"
done
done
fi
- name: Build changed projects
run: |
mapfile -t PROJECTS < <(jq -r 'to_entries[] | select( .value ) | .key' <<<"$CHANGED")
if [[ ${#PROJECTS[@]} -eq 0 ]]; then
echo "Nothing to build. Generating empty artifact."
mkdir "$BUILD_BASE"
touch "$BUILD_BASE/mirrors.txt"
else
pnpm jetpack build -v --no-pnpm-install --for-mirrors="$BUILD_BASE" "${PROJECTS[@]}"
fi
- name: Create archive
run: |
tar --owner=0 --group=0 --xz -cvvf "$FILENAME" -C "$BUILD_BASE" --transform 's,^\.,build,' .
- name: Store build as artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
path: ${{ env.FILENAME }}
retention-days: 1
archive: false
build_wpcom:
name: Build wpcom projects
runs-on: ubuntu-latest
if: &trunk_push ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
env:
FILENAME: partial-build-wpcom.tar.xz
# Hard-code a specific directory to avoid paths in vendor/composer/installed.json changing every build.
BUILD_BASE: /tmp/jetpack-build
timeout-minutes: 25 # 2026-08-18: Successful runs take ~13 minutes.
steps: *build_steps
build_nonwpcom:
name: Build non-wpcom projects
runs-on: ubuntu-latest
if: *trunk_push
env:
FILENAME: partial-build-nonwpcom.tar.xz
# Hard-code a specific directory to avoid paths in vendor/composer/installed.json changing every build.
BUILD_BASE: /tmp/jetpack-build
timeout-minutes: 25 # 2026-08-18: Successful runs seem to take ~13 minutes.
steps: *build_steps
merge_artifacts:
name: Merge build artifacts
runs-on: ubuntu-latest
timeout-minutes: 10 # 2026-04-07: Should take a minute or two.
needs: [ reminder_comment, build_all, build_wpcom, build_nonwpcom ]
permissions:
# actions/checkout, actions/upload-artifact, actions/download-artifact
contents: read
# Comment posting
pull-requests: write
env:
BUILD_BASE: ${{ github.workspace }}/build
# Have to check the probably-skipped build jobs manually, by default GH will skip this job if any of them skipped.
if: >
! cancelled() &&
( needs.build_all.result == 'success' || needs.build_all.result == 'skipped' ) &&
( needs.build_wpcom.result == 'success' || needs.build_wpcom.result == 'skipped' ) &&
( needs.build_nonwpcom.result == 'success' || needs.build_nonwpcom.result == 'skipped' ) &&
( needs.build_all.result == 'success' || needs.build_wpcom.result == 'success' || needs.build_nonwpcom.result == 'success' )
steps:
- name: Download build artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
pattern: partial-build-*.tar.xz
merge-multiple: true
- name: Extract and merge build archives
run: |
mkdir merged
touch merged.mirrors.txt
for ARCHIVE in partial-build-*.tar.xz; do
echo "::group::Extracting $ARCHIVE"
mkdir build
tar --xz -k -xvvf "$ARCHIVE" build
echo "::endgroup::"
for MIRROR in $(< build/mirrors.txt ); do
if [[ ! -d "merged/$MIRROR" ]]; then
echo "Copying $MIRROR from $ARCHIVE"
mkdir -p "$( dirname "merged/$MIRROR" )"
mv "build/$MIRROR" "merged/$MIRROR"
echo "$MIRROR" >> merged/mirrors.txt
elif [[ "$MIRROR" == 'Automattic/storybook' || "$MIRROR" == 'Automattic/charts' ]]; then
# Known unstable builds
echo "Ignoring $MIRROR from $ARCHIVE, already copied"
elif diff -ur "build/$MIRROR" "merged/$MIRROR" > diff.txt; then
echo "Skipping $MIRROR from $ARCHIVE, matches earlier copied build"
else
echo "::warning::Multiple builds for $MIRROR differ!"
echo "::group::Diff for $MIRROR builds"
cat diff.txt
echo "::endgroup::"
fi
done
rm -rf build
done
mv merged build
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
path: monorepo
- name: Filter mirror list for release branch
if: github.ref == 'refs/heads/prerelease' || contains( github.ref, '/branch-' )
working-directory: ./monorepo
run: .github/files/filter-mirrors-for-release-branch.sh
- name: Determine plugins to publish
id: plugins
working-directory: ./monorepo
run: |
jq -r 'if .extra["mirror-repo"] and ( .extra["beta-plugin-slug"] // .extra["wp-plugin-slug"] ) then [ ( input_filename | sub( "/composer\\.json$"; "" ) ), .extra["mirror-repo"], .extra["beta-plugin-slug"] // .extra["wp-plugin-slug"] ] else empty end | @tsv' projects/plugins/*/composer.json | while IFS=$'\t' read -r SRC MIRROR SLUG; do
if [[ -e "$BUILD_BASE/$MIRROR" ]] && grep -q --fixed-strings --line-regexp "$MIRROR" "$BUILD_BASE/mirrors.txt"; then
printf '%s\t%s\t%s\n' "$SRC" "$MIRROR" "$SLUG"
fi
done > "$BUILD_BASE/plugins.tsv"
if [[ ! -s "$BUILD_BASE/plugins.tsv" ]]; then
echo "No plugins were built"
echo "any=false" >> "$GITHUB_OUTPUT"
exit 0
fi
cat "$BUILD_BASE/plugins.tsv"
echo "any=true" >> "$GITHUB_OUTPUT"
- name: Create merged archive
run: |
tar --owner=0 --group=0 --xz -cvvf jetpack-build.tar.xz -C "$BUILD_BASE" --transform 's,^\.,build,' .
- name: Prepare plugin zips
if: steps.plugins.outputs.any == 'true'
id: plugin-zips
env:
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
mkdir work
mkdir zips
# Current version must compare greather than any previously used current version for this PR.
# Assume GH run IDs are monotonic.
VERSUFFIX="${GITHUB_RUN_ID}-g${SHA:0:8}"
ANY_BUILT=false
while IFS=$'\t' read -r SRC MIRROR SLUG; do
echo "::group::$MIRROR (src=$SRC slug=$SLUG)"
if [[ ! -e "build/$MIRROR" ]]; then
echo "Plugin was not built, skipping."
echo "::endgroup::"
continue
fi
if ! grep -q --fixed-strings --line-regexp "$MIRROR" build/mirrors.txt; then
echo "Plugin is not being mirrored in this build, skipping."
echo "::endgroup::"
continue
fi
# The Jetpack Beta Tester plugin needs the base directory name to be like "${SLUG}-dev", so copy it over.
mv "build/$MIRROR" "work/${SLUG}-dev"
# Copy testing docs that are not included in the mirror.
if [[ -e "$SRC/to-test.md" ]]; then
cp "$SRC/to-test.md" "work/${SLUG}-dev/"
fi
# Extract and update version.
CURRENT_VERSION=$(monorepo/tools/plugin-version.sh "work/${SLUG}-dev/")-$VERSUFFIX
echo "Using version $CURRENT_VERSION"
echo "$CURRENT_VERSION" > "work/${SLUG}-dev/version.txt"
# Don't use plugin-version.sh here, updating JETPACK__VERSION would clutter stats.
sed -i -e 's/Version: .*$/Version: '"$CURRENT_VERSION"'/' "work/${SLUG}-dev"/*.php
# Remove .github directory.
rm -rf "work/${SLUG}-dev/.github"
# Zip the plugin
( cd work && zip -9 -r "../zips/${SLUG}-dev.zip" "${SLUG}-dev" )
ANY_BUILT=true
echo "::endgroup::"
done < build/plugins.tsv
if ! $ANY_BUILT; then
echo "No plugins were built"
fi
echo "any-built=$ANY_BUILT" >> "$GITHUB_OUTPUT"
- name: Store build as artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
path: jetpack-build.tar.xz
# Retain trunk builds for 7 days so we can manually download for branch comparisons. Branch builds only need one day so the beta builder can slurp it up to distribute.
retention-days: ${{ case( github.ref == 'refs/heads/trunk', 7, 1 ) }}
archive: false
- name: Store plugins.tsv as artifact
if: steps.plugins.outputs.any == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
path: ${{ env.BUILD_BASE }}/plugins.tsv
# We don't really care about this artifact, its presence is a flag to the post-build job.
retention-days: 1
archive: false
- name: Create plugins artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: steps.plugin-zips.outputs.any-built == 'true'
with:
name: plugins
path: zips
# Only need to retain for a day since the beta builder slurps it up to distribute.
retention-days: 1
# Already compressed.
compression-level: 0
- name: Update reminder with testing instructions
id: update-reminder-comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
if: ${{ needs.reminder_comment.result == 'success' && fromJSON(needs.reminder_comment.outputs.comment_id)['commentId'] != 0 }}
env:
BRANCH_NAME: ${{ github.head_ref }}
DATA: ${{ needs.reminder_comment.outputs.comment_id }}
with:
script: |
const { checkTestReminderComment } = require('./monorepo/.github/files/build-reminder-comment/check-test-reminder-comment.js')
await checkTestReminderComment( github, context, core );
# GitHub provides no way to make sure the `update_wpcom_mirrors` jobs run in merge order.
# So we poll for the previous commit's Build run, and only let our `update_wpcom_mirrors` get queued when that run's `update_wpcom_mirrors` is already queued.
await_update_wpcom_mirrors:
name: Wait for previous commit wpcom-mirrors push
runs-on: ubuntu-latest
needs: [ build_wpcom ]
if: github.event_name == 'push' && github.repository == 'Automattic/jetpack'
# No timeout, might take arbitrary amounts of time.
permissions:
# Polling
actions: read
# actions/checkout
contents: read
env:
GH_TOKEN: ${{ github.token }}
AWAIT_JOB_NAME: 'Push wpcom plugins to mirror repos'
BUILD_JOB_NAMES: '[ "Build wpcom projects" ]'
steps: &await_mirrors_steps
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 2
# We don't need any files for this check, just the tree. A non-cone sparse checkout with a custom filter does the trick.
sparse-checkout-cone-mode: false
sparse-checkout: .
filter: 'tree:0'
- name: Wait for previous commit to queue
run: |
# First, get the previous commit sha
SHA=$( git log -1 --format='%H' HEAD^ || true )
[[ -z "$SHA" ]] && { echo "🤷 Failed to fetch previous commit sha. May as well go for it."; exit 0; }
# Look up the run for that sha
JSON=$( gh api -X GET "/repos/$GITHUB_REPOSITORY/actions/workflows/build.yml/runs" -F event=push -F head_sha="$SHA" --jq '.workflow_runs[0]' || true )
RUN_ID=$( jq '.id // empty' <<<"$JSON" || true )
[[ -z "$RUN_ID" ]] && { echo "🤷 Failed to find build run for $SHA. May as well go for it."; exit 0; }
echo "Watching run https://github.com/$GITHUB_REPOSITORY/actions/runs/$RUN_ID"
CONCLUSION=$( jq '.conclusion // null' <<<"$JSON" || true )
if [[ "$CONCLUSION" != "null" ]]; then
echo "🎉 Workflow for $SHA already concluded ($CONCLUSION). No need to wait on it."
exit 0
fi
# To avoid spending too much rate limit, we only re-check the run status after 15 minutes and then every 5 thereafter.
NEXTRUNCHECK=$( jq '[ now + 5 * 60, ( .created_at | 15 * 60 + fromdateiso8601 ) ] | max | round' <<<"$JSON" || true )
# Now poll the run until the target job name shows up
BADCT=0
while true; do
JSON=$( gh api -X GET "/repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/jobs" -F filter=latest -F per_page=100 || true )
if ! jq -e '.jobs' <<<"$JSON" &>/dev/null; then
BADCT=$(( BADCT + 1 ))
if [[ $BADCT -ge 3 ]]; then
echo "🤷 Repeated bad JSON. Giving up."
exit 0
fi
echo "⏱️ Bad JSON. Will retry."
sleep 30
continue
fi
BADCT=0
if jq -e --arg NAME "$AWAIT_JOB_NAME" '.jobs[] | select( .name == $NAME )' <<<"$JSON" &>/dev/null; then
echo "🎉 Found the \"$AWAIT_JOB_NAME\" job!"
exit 0
fi
# No job yet. Figure out how long to sleep, and maybe check that the watched job is still running at all.
if [[ $NEXTRUNCHECK -le $EPOCHSECONDS ]]; then
JSON2=$( gh api -X GET "/repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID" || true )
if ! jq -e '.id // empty' <<<"$JSON2" &>/dev/null; then
echo "Bad JSON when re-checking run conclusion. Will try again later."
else
CONCLUSION=$( jq '.conclusion // null' <<<"$JSON2" || true )
if [[ "$CONCLUSION" != "null" ]]; then
echo "🤷 Workflow $RUN_ID for $SHA has concluded ($CONCLUSION), despite no \"$AWAIT_JOB_NAME\" being found. May as well go ahead."
exit 0
fi
NEXTRUNCHECK=$(( EPOCHSECONDS + 5 * 60 ))
fi
fi
DELAY=$( jq --argjson BUILDS "$BUILD_JOB_NAMES" '.jobs | map( select( .name as $N | $BUILDS | index( $N ) ) | .started_at | fromdateiso8601 ) | max // now | 10 * 60 - ( now - . ) | round' <<<"$JSON" || true )
[[ "$DELAY" =~ ^[0-9]+$ ]] || DELAY=30
[[ "$DELAY" -ge 30 ]] || DELAY=30
[[ "$DELAY" -le 120 ]] || DELAY=120
echo "⏱️ No \"$AWAIT_JOB_NAME\" job yet, waiting $DELAY seconds"
sleep "$DELAY"
done
update_wpcom_mirrors:
name: Push wpcom plugins to mirror repos
runs-on: ubuntu-latest
needs: [ await_update_wpcom_mirrors ]
if: github.event_name == 'push' && github.repository == 'Automattic/jetpack'
concurrency:
group: build-push_wpcom
queue: max
timeout-minutes: 10 # 2026-05-21: Successful runs seem to take a few minutes
steps:
- name: Download build artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: partial-build-wpcom.tar.xz
- name: Extract build archive
run: |
mkdir build
tar --xz -k -xvvf partial-build-wpcom.tar.xz build
- name: Filter mirrors.txt
run: |
# We only want to push certain plugins here.
grep -Fx -e 'Automattic/jetpack-production' -e 'Automattic/jetpack-mu-wpcom-plugin' build/mirrors.txt > build/mirrors.txt.tmp || true
mv build/mirrors.txt.tmp build/mirrors.txt
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
path: monorepo
- name: Push changed projects
uses: $/projects/github-actions/push-to-mirrors
with:
source-directory: ${{ github.workspace }}/monorepo
token: ${{ secrets.API_TOKEN_GITHUB }}
upstream-ref-since: '2024-04-10' # No point in checking 12 years of earlier commits from before we started adding "Upstream-Ref".
username: matticbot
working-directory: ${{ github.workspace }}/build
# Ditto for `update_all_mirrors`.
await_update_all_mirrors:
name: Wait for previous commit all-mirrors push
runs-on: ubuntu-latest
needs: [ merge_artifacts ]
# Have to check success manually, GitHub's default sees that merge_artifacts depends on a build job that skipped and skips otherwise. 🙄
if: >
! cancelled() &&
github.event_name == 'push' && github.repository == 'Automattic/jetpack' &&
needs.merge_artifacts.result == 'success'
# No timeout, might take arbitrary amounts of time.
permissions:
# Polling
actions: read
# actions/checkout
contents: read
env:
GH_TOKEN: ${{ github.token }}
AWAIT_JOB_NAME: 'Push to mirror repos'
BUILD_JOB_NAMES: '[ "Build all projects", "Build wpcom projects", "Build non-wpcom projects" ]'
steps: *await_mirrors_steps
update_all_mirrors:
name: Push to mirror repos
runs-on: ubuntu-latest
needs: [ merge_artifacts, await_update_all_mirrors ]
concurrency:
group: build-push_all
queue: max
timeout-minutes: 10 # 2026-05-21: Successful runs seem to take a few minutes
# Have to check success manually, GitHub's default sees that merge_artifacts depends on a build job that skipped and skips otherwise. 🙄
if: >
! cancelled() &&
github.event_name == 'push' && github.repository == 'Automattic/jetpack' &&
needs.merge_artifacts.result == 'success'
steps:
- name: Download build artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: jetpack-build.tar.xz
- name: Extract build archive
run: |
mkdir build
tar --xz -k -xvvf jetpack-build.tar.xz build
- name: Filter mirrors.txt
if: *trunk_push
run: |
# Skip the plugins pushed by update_wpcom_mirrors, if it was supposed to have run.
grep -vFx -e 'Automattic/jetpack-production' -e 'Automattic/jetpack-mu-wpcom-plugin' build/mirrors.txt > build/mirrors.txt.tmp || true
mv build/mirrors.txt.tmp build/mirrors.txt
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
path: monorepo
- name: Push changed projects
uses: $/projects/github-actions/push-to-mirrors
with:
source-directory: ${{ github.workspace }}/monorepo
token: ${{ secrets.API_TOKEN_GITHUB }}
upstream-ref-since: '2024-04-10' # No point in checking 12 years of earlier commits from before we started adding "Upstream-Ref".
username: matticbot
working-directory: ${{ github.workspace }}/build
timeout-minutes: 10 # 2025-11-06: Successful runs seem to take a minute or two.