From 6281b89eb489f521f45346659a5ea221578f19c2 Mon Sep 17 00:00:00 2001 From: Anna Geller Date: Fri, 20 Dec 2024 14:23:20 +0100 Subject: [PATCH] feat: add support for multi-platform builds --- .github/workflows/main.yml | 35 +++++++++++++++++++++------------ .github/workflows/scheduled.yml | 2 +- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7829cde..81d0659 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,52 +9,60 @@ 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: @@ -62,3 +70,4 @@ jobs: push: true tags: ${{ steps.image-tag.outputs.image_url }} file: ${{ steps.image-tag.outputs.file }} + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index ac419b6..01c28a1 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -1,4 +1,4 @@ -name: Container Image Packages +name: Scheduled Container Image Packages on: schedule: