From 4a83a0a4e22a9c1dfad8b9efd1106fbe3e4c7ba8 Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 19:14:03 +0530 Subject: [PATCH 1/6] GHCR- Push Update backup repo images to push their docker image to GHCR Packages registry --- .github/workflows/build-and-publish.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 65d09e0..f359e71 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -17,16 +17,29 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} - - name: Build and push Docker image + - name: Build and push Docker image to Docker Hub uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker image to GitHub Container Registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.meta.outputs.tags }} From 32c22eb2f728a6ef067d5e18105cfb162480ca6c Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 19:42:27 +0530 Subject: [PATCH 2/6] GHCR -image push Update backup repo images to push their docker image to GHCR Packages registry --- .github/workflows/build-and-publish.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index f359e71..cd4b307 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -29,6 +29,9 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} + # Add an additional configuration to ensure valid tags + tags: | + ${{ github.ref }} # This will take the branch name or tag name - name: Build and push Docker image to Docker Hub uses: docker/build-push-action@v5 @@ -42,4 +45,8 @@ jobs: with: context: . push: true - tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.meta.outputs.tags }} + # 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 }} From 1238757840aa75cc1e76a84c833384813ef66db0 Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 15:21:21 +0530 Subject: [PATCH 3/6] Pushing the image both in DockerHub and GitHub -GHCR.io in the develop branch --- .github/workflows/build-and-publish.yml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index cd4b307..47b60aa 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -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 @@ -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 }} From b0d6e2ee1f37baf00ea013e9c93ed77778bf52f5 Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 15:23:13 +0530 Subject: [PATCH 4/6] Pushing the image both in DockerHub and GitHub -GHCR.io in the main branch --- .github/workflows/build-and-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 47b60aa..f6147fe 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -3,7 +3,7 @@ name: Build and Publish on: push: branches: - - develop + - main jobs: build-and-publish: @@ -35,7 +35,7 @@ jobs: ghcr.io/${{ github.repository }} tags: | type=ref,event=branch # Tag with branch name - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - name: Build and push Docker image to Docker Hub and GHCR uses: docker/build-push-action@v5 From 9009de2b741bfb0b3e0a3091032d5be3e839c4b5 Mon Sep 17 00:00:00 2001 From: Praveen Date: Mon, 7 Oct 2024 17:37:04 +0530 Subject: [PATCH 5/6] updated the branch udpated the branch and version tags --- .github/workflows/build-and-publish.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index f6147fe..31841cc 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -2,12 +2,12 @@ name: Build and Publish on: push: - branches: - - main + branches: [ 'main' ] # Trigger on push to 'main' + tags: [ '[0-9]+.[0-9]+.[0-9]+' ] # Trigger on version tags like '0.1.0' jobs: build-and-publish: - name: Build and Publish Docker Image + name: Build and Publish Docker image runs-on: ubuntu-latest steps: - name: Checkout code @@ -35,9 +35,15 @@ jobs: ghcr.io/${{ github.repository }} tags: | type=ref,event=branch # Tag with branch name - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + # labels: | + # org.opencontainers.image.source=${{ github.repository }} + # org.opencontainers.image.revision=${{ github.sha }} + # org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} - - name: Build and push Docker image to Docker Hub and GHCR + - name: Build and push Docker image to DockerHub and GHCR uses: docker/build-push-action@v5 with: context: . From 6e49cb1efc3a9f089a1a25c899500eadae72fe7e Mon Sep 17 00:00:00 2001 From: Praveen Date: Tue, 8 Oct 2024 11:25:17 +0530 Subject: [PATCH 6/6] branch setting --- .github/workflows/build-and-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 31841cc..78dd850 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -2,7 +2,7 @@ name: Build and Publish on: push: - branches: [ 'main' ] # Trigger on push to 'main' + branches: [ 'main', 'master' ] # Trigger on push to 'main'& 'master' master will be remove step by step tags: [ '[0-9]+.[0-9]+.[0-9]+' ] # Trigger on version tags like '0.1.0' jobs: