1
- name : Dockerhub Push
1
+ name : Multi-platform Docker Image Push
2
2
3
3
# Controls when the workflow will run
4
4
on :
5
- # Triggers the workflow on push or pull request events but only for the "master" branch
6
5
push :
7
- branches : [ "master" ]
6
+ branches : [ '*' ]
7
+ # Publish semver tags as releases.
8
+ tags : [ 'v*.*.*' ]
8
9
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 : .
10
17
11
18
# Allows you to run this workflow manually from the Actions tab
12
19
workflow_dispatch :
@@ -28,13 +35,39 @@ jobs:
28
35
- name : Setup Docker Buildx
29
36
uses : docker/setup-buildx-action@v3
30
37
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') }}
33
61
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
36
67
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