Skip to content

Commit 1238757

Browse files
committed
Pushing the image both in DockerHub and GitHub -GHCR.io in the develop branch
1 parent 32c22eb commit 1238757

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

.github/workflows/build-and-publish.yml

+9-15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: Build and Publish
22

33
on:
44
push:
5+
branches:
6+
- develop
57

68
jobs:
79
build-and-publish:
8-
name: Build and Publish
10+
name: Build and Publish Docker Image
911
runs-on: ubuntu-latest
1012
steps:
1113
- name: Checkout code
@@ -28,25 +30,17 @@ jobs:
2830
id: meta
2931
uses: docker/metadata-action@v5
3032
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 }}
3336
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') }}
3539
36-
- name: Build and push Docker image to Docker Hub
40+
- name: Build and push Docker image to Docker Hub and GHCR
3741
uses: docker/build-push-action@v5
3842
with:
3943
context: .
4044
push: true
4145
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 }}
5246
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)