-
Notifications
You must be signed in to change notification settings - Fork 36
62 lines (50 loc) · 1.63 KB
/
build-test.yml
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
name: Docker Image Build
on:
push:
branches: [ master ]
paths:
- '*/Dockerfile'
- '.github/workflows/build-test.yml'
pull_request:
branches: [ master ]
paths:
- '*/Dockerfile'
- '.github/workflows/build-test.yml'
jobs:
files:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.dockerfile.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Get changed files
id: files
uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 # v1
with:
format: json
- name: Extract Dockerfile files
id: dockerfile
run: |
FILES=$( echo '${{ steps.files.outputs.added_modified }}' | jq -c 'map(select(. | endswith("Dockerfile")))' )
echo "matrix=$FILES" >> "$GITHUB_OUTPUT"
build:
runs-on: ubuntu-latest
needs: files
strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJSON(needs.files.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up QEMU
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- name: Build Docker image ${{ matrix.dockerfile }}
run: |
cd "$(dirname ${{ matrix.dockerfile }})"
docker buildx build --platform linux/amd64,linux/arm64 . --file Dockerfile