Skip to content

Commit d1b001e

Browse files
authored
Merge pull request brefphp#49 from depot/buildx-fallback
2 parents 4e108e1 + c696078 commit d1b001e

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

.github/workflows/tests.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,38 @@ permissions:
1313
contents: read
1414

1515
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+
1641
tests:
1742
name: Build and tests PHP ${{ matrix.php_version }}, ${{ matrix.cpu }}
1843
runs-on: ubuntu-latest
44+
needs: matrix-prep
1945
strategy:
2046
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) }}
2948
steps:
3049
- uses: actions/checkout@v3
3150

@@ -34,13 +53,16 @@ jobs:
3453
uses: docker/setup-qemu-action@v2
3554

3655
- uses: depot/setup-action@v1
56+
- uses: docker/setup-buildx-action@v2
3757

3858
# We use this action instead of running `make docker-images-php-XX` directly because it lets us
3959
# use OIDC authentication instead of a secret. Secrets can't be used in pull request builds.
4060
- name: Build Docker images
4161
uses: depot/bake-action@v1
4262
with:
4363
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 }}
4466
env:
4567
CPU: ${{ matrix.cpu }}
4668
CPU_PREFIX: ${{ (matrix.cpu == 'arm') && 'arm-' || '' }}

0 commit comments

Comments
 (0)