Skip to content

Commit 921ff31

Browse files
authored
Update builder_release.yml to use Docker Buildx for multi-platform image building (#45)
This pull request updates the builder_release.yml file to use Docker Buildx for multi-platform image building. The changes include setting up Docker Buildx, logging in to the Container registry, extracting metadata for Docker, and building and pushing the Docker image. The update also adds support for building images for both Linux AMD64 and Linux ARM64 platforms.
2 parents 4cb055b + 06907fd commit 921ff31

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

.github/workflows/builder_release.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ name: Publish to GHCR
33

44
# Configures this workflow to run every time a change is pushed to the branch called `release`.
55
on:
6-
push:
7-
branches: ['release']
6+
release:
7+
types: [published]
88
workflow_dispatch:
99

1010
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
1111
env:
1212
REGISTRY: ghcr.io
13-
IMAGE_NAME: ${{ github.repository }}_noha
1413

1514
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
1615
jobs:
@@ -24,26 +23,30 @@ jobs:
2423
steps:
2524
- name: Checkout repository
2625
uses: actions/checkout@v4
26+
# This step sets up the Docker Buildx builder. This allows the workflow to build and push multi-platform images.
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
2729
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
2830
- name: Log in to the Container registry
29-
uses: docker/login-action@v3.1
31+
uses: docker/login-action@v3
3032
with:
3133
registry: ${{ env.REGISTRY }}
32-
username: ${{ github.actor }}
34+
username: ${{ github.repository_owner }}
3335
password: ${{ secrets.GITHUB_TOKEN }}
3436
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
3537
- name: Extract metadata (tags, labels) for Docker
3638
id: meta
37-
uses: docker/metadata-action@v5.1
39+
uses: docker/metadata-action@v5
3840
with:
39-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
images: ${{ env.REGISTRY }}/${{ github.repository }}-noha
4042
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
4143
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
4244
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
4345
- name: Build and push Docker image
44-
uses: docker/build-push-action@v5.3
46+
uses: docker/build-push-action@v5
4547
with:
4648
context: .
4749
push: true
50+
platforms: linux/amd64,linux/arm64
4851
tags: ${{ steps.meta.outputs.tags }}
4952
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)