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 99a3ef0 commit 45bb767
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ jobs:
outputs:
matrix: ${{ steps.dockerfiles.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- id: dockerfiles
run: echo "matrix=$(ls dockerfiles-manual/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
run: echo "matrix=$(ls dockerfiles-manual/ | jq -R -s -c 'split(\"\\n\")[:-1]')" >> $GITHUB_OUTPUT

ghcr:
runs-on: ubuntu-latest
Expand All @@ -20,29 +22,36 @@ jobs:
contents: read
packages: write
strategy:
matrix:
matrix:
image: ${{ fromJson(needs.list-dockerfiles.outputs.matrix) }}
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=dockerfiles-manual/${{ 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
23 changes: 16 additions & 7 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ jobs:
outputs:
matrix: ${{ steps.dockerfiles.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- id: dockerfiles
run: echo "matrix=$(ls dockerfiles/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
run: echo "matrix=$(ls dockerfiles/ | jq -R -s -c 'split(\"\\n\")[:-1]')" >> $GITHUB_OUTPUT

ghcr:
runs-on: ubuntu-latest
Expand All @@ -25,19 +27,25 @@ jobs:
matrix:
image: ${{ fromJson(needs.list-dockerfiles.outputs.matrix) }}
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=dockerfiles/${{ matrix.image }}" >> $GITHUB_OUTPUT
Expand All @@ -47,4 +55,5 @@ jobs:
context: .
push: true
tags: ${{ steps.image-tag.outputs.image_url }}
file: ${{ steps.image-tag.outputs.file }}
file: ${{ steps.image-tag.outputs.file }}
platforms: linux/amd64,linux/arm64

0 comments on commit 45bb767

Please sign in to comment.