@@ -2,8 +2,6 @@ name: Test and Publish
2
2
3
3
on :
4
4
push :
5
- branches : [ 'main' ] # Triger on the main branch
6
- tags : [ '[0-9]+.[0-9]+.[0-9]+' ] # Trigger on version tags like '0.1.0'
7
5
8
6
jobs :
9
7
tests :
@@ -39,27 +37,35 @@ jobs:
39
37
40
38
- name : Log in to GitHub Container Registry
41
39
uses : docker/login-action@v3
40
+ if : startsWith(github.ref, 'refs/tags')
42
41
with :
43
- registry : ghcr.io
44
- username : ${{ github.actor }}
45
- password : ${{ secrets.GITHUB_TOKEN }}
42
+ registry : ghcr.io
43
+ username : ${{ github.actor }}
44
+ password : ${{ secrets.GITHUB_TOKEN }}
46
45
47
46
- name : Extract metadata (tags, labels) for Docker
48
47
id : meta
49
48
uses : docker/metadata-action@v5
50
49
with :
51
- images : |
52
- ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
53
- ghcr.io/${{ github.repository }}
50
+ images : ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
54
51
tags : |
55
52
type=ref,event=branch
56
53
type=semver,pattern={{version}}
57
54
type=semver,pattern={{major}}.{{minor}}
58
-
59
- - name : Build and push Docker image
55
+
56
+ - name : Build and push Docker image to Docker Hub
60
57
uses : docker/build-push-action@v5
61
58
with :
62
59
context : .
63
60
push : true
64
61
tags : ${{ steps.meta.outputs.tags }}
65
62
labels : ${{ steps.meta.outputs.labels }}
63
+
64
+ - name : Build and push Docker image to GitHub Container Registry
65
+ uses : docker/build-push-action@v5
66
+ if : startsWith(github.ref, 'refs/tags')
67
+ with :
68
+ context : .
69
+ push : true
70
+ tags : ghcr.io/${{ github.repository }}:${{ github.ref_name }}
71
+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments