@@ -2,10 +2,12 @@ name: Build and Publish
2
2
3
3
on :
4
4
push :
5
+ branches :
6
+ - develop
5
7
6
8
jobs :
7
9
build-and-publish :
8
- name : Build and Publish
10
+ name : Build and Publish Docker Image
9
11
runs-on : ubuntu-latest
10
12
steps :
11
13
- name : Checkout code
@@ -28,25 +30,17 @@ jobs:
28
30
id : meta
29
31
uses : docker/metadata-action@v5
30
32
with :
31
- images : ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
32
- # Add an additional configuration to ensure valid tags
33
+ images : |
34
+ ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
35
+ ghcr.io/${{ github.repository }}
33
36
tags : |
34
- ${{ github.ref }} # This will take the branch name or tag name
37
+ type=ref,event=branch # Tag with branch name
38
+ type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
35
39
36
- - name : Build and push Docker image to Docker Hub
40
+ - name : Build and push Docker image to Docker Hub and GHCR
37
41
uses : docker/build-push-action@v5
38
42
with :
39
43
context : .
40
44
push : true
41
45
tags : ${{ steps.meta.outputs.tags }}
42
-
43
- - name : Build and push Docker image to GitHub Container Registry
44
- uses : docker/build-push-action@v5
45
- with :
46
- context : .
47
- push : true
48
- # Create a valid tag for the GitHub Container Registry
49
- tags : |
50
- ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
51
- ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
52
46
labels : ${{ steps.meta.outputs.labels }}
0 commit comments