@@ -13,19 +13,38 @@ permissions:
13
13
contents : read
14
14
15
15
jobs :
16
+ matrix-prep :
17
+ name : Prepare matrix
18
+ runs-on : ubuntu-latest
19
+ outputs :
20
+ matrix : ${{ steps.set-matrix.outputs.result }}
21
+ steps :
22
+ - uses : actions/github-script@v6
23
+ id : set-matrix
24
+ with :
25
+ script : |
26
+ const matrix = {
27
+ cpu: ['x86', 'arm'],
28
+ php_version: ['80', '81', '82'],
29
+ }
30
+
31
+ // If this is a third-party pull request, skip ARM builds
32
+ if (context.eventName === 'pull_request') {
33
+ const pr = context.payload.pull_request
34
+ if (pr.head.repo.full_name !== pr.base.repo.full_name) {
35
+ matrix.cpu = ['x86']
36
+ }
37
+ }
38
+
39
+ return matrix
40
+
16
41
tests :
17
42
name : Build and tests PHP ${{ matrix.php_version }}, ${{ matrix.cpu }}
18
43
runs-on : ubuntu-latest
44
+ needs : matrix-prep
19
45
strategy :
20
46
fail-fast : false
21
- matrix :
22
- cpu :
23
- - x86
24
- - arm
25
- php_version :
26
- - 80
27
- - 81
28
- - 82
47
+ matrix : ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
29
48
steps :
30
49
- uses : actions/checkout@v3
31
50
@@ -34,13 +53,16 @@ jobs:
34
53
uses : docker/setup-qemu-action@v2
35
54
36
55
- uses : depot/setup-action@v1
56
+ - uses : docker/setup-buildx-action@v2
37
57
38
58
# We use this action instead of running `make docker-images-php-XX` directly because it lets us
39
59
# use OIDC authentication instead of a secret. Secrets can't be used in pull request builds.
40
60
- name : Build Docker images
41
61
uses : depot/bake-action@v1
42
62
with :
43
63
load : true
64
+ # If this is an third-party pull request, fall back to the local buildx builder
65
+ buildx-fallback : ${{ github.event.pull_request.head.repo.full_name != github.repository }}
44
66
env :
45
67
CPU : ${{ matrix.cpu }}
46
68
CPU_PREFIX : ${{ (matrix.cpu == 'arm') && 'arm-' || '' }}
0 commit comments