|
1 | | -name: Build image(s) on PR |
| 1 | +name: Build image(s) on PR/push |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: |
5 | 5 | paths: |
6 | | - - ci/images/Dockerfile.* |
| 6 | + - ci/images/**/Dockerfile.* |
| 7 | + push: |
| 8 | + paths: |
| 9 | + - ci/images/**/Dockerfile.* |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 13 | + cancel-in-progress: true |
7 | 14 |
|
8 | 15 | permissions: {} |
9 | 16 |
|
10 | 17 | jobs: |
| 18 | + filter: |
| 19 | + if: github.repository == 'CycloneDX/cdxgen' |
| 20 | + runs-on: ubuntu-24.04 |
| 21 | + outputs: |
| 22 | + imagefiles: ${{ steps.changed.outputs.files }} |
| 23 | + steps: |
| 24 | + - name: Get changed files |
| 25 | + id: changed |
| 26 | + uses: actions/github-script@v7 |
| 27 | + with: |
| 28 | + script: | |
| 29 | + const response = await github.rest.repos.compareCommits({ |
| 30 | + owner: context.repo.owner, |
| 31 | + repo: context.repo.repo, |
| 32 | + base: context.payload.before, |
| 33 | + head: context.payload.after |
| 34 | + }); |
| 35 | + const files = response.data.files |
| 36 | + .map(f => f.filename) |
| 37 | + .filter(f => f.includes("Dockerfile")); |
| 38 | + core.setOutput("files", JSON.stringify(files)); |
11 | 39 | image: |
12 | 40 | if: github.repository == 'CycloneDX/cdxgen' |
| 41 | + needs: filter |
13 | 42 | strategy: |
14 | 43 | fail-fast: false |
15 | 44 | matrix: |
16 | | - imagefile: ${{ github.event.head_commit.modified }} |
17 | | - runner: [ubuntu-24.04, ubuntu-24.04-arm] |
18 | | - include: |
19 | | - - runner: ubuntu-24.04 |
20 | | - platform: linux/amd64 |
21 | | - - runner: ubuntu-24.04-arm |
22 | | - platform: linux/arm64 |
23 | | - runs-on: ${{ matrix.runner }} |
| 45 | + imagefile: ${{ fromJson(needs.filter.outputs.imagefiles) }} |
| 46 | + platform: [ amd64, arm64 ] |
| 47 | + # Some images don't work on linux/arm64 |
| 48 | + exclude: |
| 49 | + - imagefile: ci/images/Dockerfile.dotnet7 |
| 50 | + platform: arm64 |
| 51 | + - imagefile: ci/images/Dockerfile.dotnet8 |
| 52 | + platform: arm64 |
| 53 | + - imagefile: ci/images/Dockerfile.dotnet9 |
| 54 | + platform: arm64 |
| 55 | + - imagefile: ci/images/Dockerfile.ruby25 |
| 56 | + platform: arm64 |
| 57 | + - imagefile: ci/images/debian/Dockerfile.ruby26 |
| 58 | + platform: arm64 |
| 59 | + runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }} |
24 | 60 | steps: |
| 61 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 62 | + with: |
| 63 | + persist-credentials: false |
25 | 64 | - name: Build image |
26 | | - if: ${{ contains(matrix.imagefile, 'Dockerfile') }} |
27 | 65 | uses: ./.github/actions/build-docker-image |
28 | 66 | with: |
29 | 67 | dockerfile: ${{ matrix.imagefile }} |
|
0 commit comments