feat(images): Build multi-arch images #367
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: files | |
uses: jitterbit/get-changed-files@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@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image ${{ matrix.dockerfile }} | |
run: | | |
cd "$(dirname ${{ matrix.dockerfile }})" | |
docker build --platform linux/amd64,linux/arm64 . --file Dockerfile |