Skip to content

Commit

Permalink
Add support for arm64 image build in workflows
Browse files Browse the repository at this point in the history
In addition fix image push trigger branch

Signed-off-by: adrianc <[email protected]>
  • Loading branch information
adrianchiris committed Sep 5, 2024
1 parent cef2b09 commit 19e72bb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 118 deletions.
70 changes: 0 additions & 70 deletions .github/workflows/push-main.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: push-master
on:
push:
branches:
- master
jobs:
image-build-push:
runs-on: ubuntu-latest
steps:
- name: Set repository as lower-case output variable
id: repo_name
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')

- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo_name.outputs.repository }}

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

- name: Push to GitHub Container Registry
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ steps.repo_name.outputs.repository }}:latest
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile
61 changes: 13 additions & 48 deletions .github/workflows/push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
tags:
- v*
jobs:
build-push-amd64:
name: Image push/amd64
image-build-push:
runs-on: ubuntu-latest
steps:
- name: Set repository as lower-case output variable
Expand All @@ -14,12 +13,17 @@ jobs:

- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v5
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -30,58 +34,19 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo_name.outputs.repository }}
tags: |
type=ref,event=tag
flavor: |
latest=false
- name: Push container image
- name: Build and Push container image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ steps.repo_name.outputs.repository }}:stable-amd64
${{ steps.docker_meta.outputs.tags }}-amd64
ghcr.io/${{ steps.repo_name.outputs.repository }}:stable
${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./Dockerfile

create-push-manifest:
needs: [build-push-amd64]
runs-on: ubuntu-latest
steps:
- name: Set repository as lower-case output variable
id: repo_name
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')

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

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo_name.outputs.repository }}
flavor: |
latest=false
- name: Login to GitHub Container Registry
uses: docker/login-action@v5
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest for multi-arch images
env:
REPOSITORY: ghcr.io/${{ steps.repo_name.outputs.repository }}
run: |
# Get artifacts from previous steps
docker pull ${{ steps.docker_meta.outputs.tags }}-amd64
docker pull ${{ env.REPOSITORY }}:stable-amd64
# Create and update manifests
docker manifest create ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64 --arch amd64
docker manifest create ${{ env.REPOSITORY }}:stable ${{ env.REPOSITORY }}:stable-amd64
docker manifest annotate ${{ env.REPOSITORY }}:stable ${{ env.REPOSITORY }}:stable-amd64 --arch amd64
# push manifests
docker manifest push ${{ steps.docker_meta.outputs.tags }}
docker manifest push ${{ env.REPOSITORY }}:stable

0 comments on commit 19e72bb

Please sign in to comment.