Skip to content

Commit

Permalink
feat: add docker build matrix support (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
septs authored Jun 22, 2024
1 parent 1ee2b16 commit c6ccc67
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/build-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v6
- linux/arm/v7
- linux/riscv64
permissions:
contents: read
packages: write
Expand All @@ -30,9 +39,7 @@ jobs:
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: |
linux/amd64
linux/arm64
platforms: ${{ matrix.platform }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
Expand All @@ -42,18 +49,25 @@ jobs:
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
id: dockerhub
continue-on-error: true
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Make image list
id: images
run: |
IMAGES='ghcr.io/${{ github.repository }}\n'
if ${{ steps.dockerhub.outcome == 'success' }}; then
IMAGES+='docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}\n'
fi
echo -e "images=$IMAGES" >> "$GITHUB_OUTPUT"
- name: Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
images: ${{ steps.images.outputs.images }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
Expand All @@ -62,7 +76,7 @@ jobs:
type=ref,event=branch
type=ref,event=tag
- name: Build and Push
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: ${{ github.event_name != 'pull_request' }}
target: production
Expand Down

0 comments on commit c6ccc67

Please sign in to comment.