Skip to content

Commit

Permalink
Pushing the image both in DockerHub and GitHub -GHCR.io in the develo…
Browse files Browse the repository at this point in the history
…p branch
  • Loading branch information
Praveenraj-K committed Oct 4, 2024
1 parent 32c22eb commit 1238757
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ name: Build and Publish

on:
push:
branches:
- develop

jobs:
build-and-publish:
name: Build and Publish
name: Build and Publish Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -28,25 +30,17 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
# Add an additional configuration to ensure valid tags
images: |
${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
${{ github.ref }} # This will take the branch name or tag name
type=ref,event=branch # Tag with branch name
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }}
- name: Build and push Docker image to Docker Hub
- name: Build and push Docker image to Docker Hub and GHCR
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Build and push Docker image to GitHub Container Registry
uses: docker/build-push-action@v5
with:
context: .
push: true
# Create a valid tag for the GitHub Container Registry
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 1238757

Please sign in to comment.