Skip to content

Commit

Permalink
feat: add support for multi-platform builds
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-geller committed Dec 20, 2024
1 parent 45bb767 commit 6281b89
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,65 @@ on:

jobs:
changes:
name: Dockerfile changes
name: Dockerfile Changes
runs-on: ubuntu-latest
outputs:
dockerfiles: ${{ steps.filter.outputs.dockerfiles_files }}
dockerfiles_changed: ${{ steps.filter.outputs.dockerfiles }}
steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3

- name: Filter Dockerfile changes
uses: dorny/paths-filter@v3
id: filter
with:
list-files: json
filters: |
dockerfiles:
- added|modified: 'dockerfiles/*.Dockerfile'
- name: Generate Markdown Summary
run: |
echo New/modified Dockerfiles: ${{ steps.filter.outputs.dockerfiles_files }} >> $GITHUB_STEP_SUMMARY
run: echo "New/modified Dockerfiles: ${{ steps.filter.outputs.dockerfiles_files }}" >> $GITHUB_STEP_SUMMARY

ghcr:
needs: [changes]
needs: changes
if: ${{ needs.changes.outputs.dockerfiles_changed == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
matrix:
image: ${{ fromJson(needs.changes.outputs.dockerfiles) }}
steps:
- name: checkout
- name: Checkout repository
uses: actions/checkout@v4

- name: GHCR Login
uses: docker/login-action@v2
- name: Set up QEMU for cross-platform builds
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: image-tag # example output: "ghcr.io/kestra-io/pydata:latest"
run: |
export IMAGE=$(basename ${{ matrix.image }} .Dockerfile)
IMAGE=$(basename ${{ matrix.image }} .Dockerfile)
echo "image_url=ghcr.io/kestra-io/$IMAGE:latest" >> $GITHUB_OUTPUT
echo "file=${{ matrix.image }}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.image-tag.outputs.image_url }}
file: ${{ steps.image-tag.outputs.file }}
platforms: linux/amd64,linux/arm64
2 changes: 1 addition & 1 deletion .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Container Image Packages
name: Scheduled Container Image Packages

on:
schedule:
Expand Down

0 comments on commit 6281b89

Please sign in to comment.