From 5919f84e6b6d2e5f1dafde10472193f427de6861 Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 14:50:21 +0530 Subject: [PATCH 1/7] Update build-and-publish.yml added the ghcr.io registry --- .github/workflows/build-and-publish.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index fbc0976..4cfa2c7 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -17,11 +17,20 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Log in to GitHub Container Registry using Organization API Token + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_API_TOKEN }} # Use the organization token + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: - images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} + images: | + ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} # Docker Hub image + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} # GitHub Container Registry image tags: | type=ref,event=branch type=semver,pattern={{version}} @@ -29,10 +38,18 @@ jobs: # set 'latest' tag for main branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - - 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 }} + labels: ${{ steps.meta.outputs.labels }} From 12ea894e29bec2ffd073964a36c723561035d422 Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 15:03:54 +0530 Subject: [PATCH 2/7] Update build-and-publish.yml Removed personal access key configured my git hub. Need to create "GHCR_API_TOKEN" as an org secret key From bc4be681a73121e1772b403d02374091871b058f Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 15:05:27 +0530 Subject: [PATCH 3/7] Update build-and-publish.yml From 86f300b89d8d1244aa704442c454b0e8bda06b2f Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 15:51:35 +0530 Subject: [PATCH 4/7] Update build-and-publish.yml --- .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 4cfa2c7..dd377b9 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -22,7 +22,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GHCR_API_TOKEN }} # Use the organization token + password: ${{ secrets.GITHUB_TOKEN }} # Use the organization token - name: Extract metadata (tags, labels) for Docker id: meta From 79b015dd5b4d83d68d5acf5293765b9cc4871820 Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 16:04:46 +0530 Subject: [PATCH 5/7] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 30 +++++++------------------ 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index dd377b9..259e47b 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -11,45 +11,31 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Log in to GitHub Container Registry using Organization API Token + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} # Use the organization token + 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 }} # Docker Hub image - ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} # GitHub Container Registry image + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} tags: | type=ref,event=branch type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - # set 'latest' tag for main branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - - name: Build and push Docker image to Docker Hub + - name: Build and push Docker image 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 }} + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:docker-dev + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:silintl-docker-dev labels: ${{ steps.meta.outputs.labels }} From 78c269d3728a179c0c70c761344c63f1f3791b44 Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 16:25:18 +0530 Subject: [PATCH 6/7] Update build-and-publish.yml --- .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 259e47b..98ff25d 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -37,5 +37,5 @@ jobs: push: true tags: | ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:docker-dev - ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:silintl-docker-dev + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:silintl-tfc-backup-b2 labels: ${{ steps.meta.outputs.labels }} From 9a812e8fb4fc3883a7541c2ca1765d6f37c2722f Mon Sep 17 00:00:00 2001 From: Praveenraj-K Date: Thu, 3 Oct 2024 16:36:30 +0530 Subject: [PATCH 7/7] Update build-and-publish.yml --- .github/workflows/build-and-publish.yml | 31 +++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 98ff25d..d3dd1f2 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -11,31 +11,48 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Log in to GitHub Container Registry + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Log in to GitHub Container Registry using Organization API Token uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} # Use the organization token - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: | - ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} + ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} # Docker Hub image + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} # GitHub Container Registry image tags: | type=ref,event=branch type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} + # set 'latest' tag for main branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - - 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 + push: true + # Fixed tag for GitHub Container Registry tags: | - ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:docker-dev - ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:silintl-tfc-backup-b2 + 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 }}