Skip to content

Commit daa6aa2

Browse files
committed
Updating github workflow to build multi-arch images and push to github
1 parent 8d239cf commit daa6aa2

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

.github/workflows/dockerhub-arm64-push.yml

+45-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
name: Dockerhub Push
1+
name: Multi-platform Docker Image Push
22

33
# Controls when the workflow will run
44
on:
5-
# Triggers the workflow on push or pull request events but only for the "master" branch
65
push:
7-
branches: [ "master" ]
6+
branches: [ '*' ]
7+
# Publish semver tags as releases.
8+
tags: [ 'v*.*.*' ]
89
pull_request:
9-
branches: [ "master" ]
10+
branches: [ 'master' ]
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
# github.repository as <account>/<repo>
15+
IMAGE_BASE: ${{ github.repository }}
16+
BUILD_DIR: .
1017

1118
# Allows you to run this workflow manually from the Actions tab
1219
workflow_dispatch:
@@ -28,13 +35,39 @@ jobs:
2835
- name: Setup Docker Buildx
2936
uses: docker/setup-buildx-action@v3
3037

31-
- name: Build the Docker image for arm64 platforms
32-
run: docker buildx build . --file Dockerfile --tag perfsonar-testpoint-arm64:$(date +%s) --platform linux/arm/v7
38+
# Login against a Docker registry except on PR
39+
# https://github.com/docker/login-action
40+
- name: Log into registry ${{ env.REGISTRY }}
41+
if: github.event_name != 'pull_request'
42+
uses: docker/login-action@v2
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
# Extract metadata (tags, labels) for Docker
49+
# https://github.com/docker/metadata-action
50+
- name: Extract Docker metadata
51+
id: meta
52+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
53+
with:
54+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE }}
55+
tags: |
56+
type=schedule
57+
type=ref,event=branch
58+
type=ref,event=tag
59+
type=ref,event=pr
60+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
3361
34-
- name: Publish to Docker Hub
35-
uses: docker/build-push-action@v1
62+
# Build and push Docker image with Buildx (don't push on PR)
63+
# https://github.com/docker/build-push-action
64+
- name: Build and push Docker images
65+
id: build-and-push
66+
uses: docker/build-push-action@v6
3667
with:
37-
username: ${{ secrets.DOCKER_USERNAME }}
38-
password: ${{ secrets.DOCKER_PASSWORD }}
39-
repository: cs1867/git-testpoint
40-
tags: latest
68+
context: ${{ env.BUILD_DIR }}
69+
file: ${{ env.BUILD_DIR }}/Dockerfile
70+
push: ${{ github.event_name != 'pull_request' }}
71+
tags: ${{ steps.meta.outputs.tags }}
72+
labels: ${{ steps.meta.outputs.labels }}
73+
platforms: linux/amd64,linux/arm/v7

0 commit comments

Comments
 (0)