From b65948fcaead5f518408e0e267f8f0bba9ecd1ac Mon Sep 17 00:00:00 2001 From: Shayan Ghani Date: Sat, 3 May 2025 14:22:49 +0330 Subject: [PATCH 1/4] chore(ci): added docker hub push after release added version/action-specific images --- .github/workflows/ci.yml | 11 ++------- .github/workflows/dev.yml | 9 +++----- .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b89a3f..53f4b68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,14 +11,9 @@ on: - '.gitignore' - 'LICENSE' -permissions: - contents: write - pull-requests: read env: - ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest - docker_repo_addr: shayanghani/container-exporter:latest - docker_hub_user: shayanghani + ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:${{github.action}}-${{github.run_id}} jobs: @@ -52,9 +47,7 @@ jobs: with: context: . push: true - tags: | - ${{env.ghcr_repo_addr}} - ${{env.docker_repo_addr}} + tags: ${{env.ghcr_repo_addr}} diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 1e7c593..f96f5c5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -1,4 +1,4 @@ -name: CI for development branches +name: CI-development on: push: @@ -26,15 +26,12 @@ on: - '.gitignore' - 'LICENSE' -permissions: - contents: write - pull-requests: read env: - ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest + ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:${{github.action}}-${{github.run_id}} jobs: - probe: + build-and-check: runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2274be4..84de602 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,11 +14,20 @@ on: branches: - master +permissions: + contents: write + pull-requests: read + env: ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:latest - + docker_repo_addr: shayanghani/container-exporter + docker_hub_user: shayanghani + jobs: release: + outputs: + image_tag: ${{ steps.bump.outputs.new_tag }} + if: github.event_name != 'pull_request' && github.ref_name == 'master' runs-on: ubuntu-latest steps: @@ -35,4 +44,33 @@ jobs: uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 with: body: ${{ steps.bump.outputs.changelog }} - tag_name: ${{ steps.bump.outputs.new_tag }} \ No newline at end of file + tag_name: ${{ steps.bump.outputs.new_tag }} + + docker-push: + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ env.docker_hub_user }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push to Dockerhub + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + "${{env.docker_repo_addr}}:${{ needs.release.outputs.image_tag }}" + "${{env.docker_repo_addr}}:latest" + \ No newline at end of file From bb8b7ed05c5d322437b5806e5b6a40615b57d942 Mon Sep 17 00:00:00 2001 From: Shayan Ghani Date: Sat, 3 May 2025 14:26:10 +0330 Subject: [PATCH 2/4] fix(ci): removed docker hub login --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53f4b68..9e53172 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,12 +23,6 @@ jobs: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ env.docker_hub_user }} - password: ${{ secrets.DOCKER_TOKEN }} - - name: Login to GHCR uses: docker/login-action@v3 with: From b6cd26d53d62221300805444e50ad3a50fc5c750 Mon Sep 17 00:00:00 2001 From: Shayan Ghani Date: Sat, 3 May 2025 14:29:29 +0330 Subject: [PATCH 3/4] fix(ci): ghcr image naming --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e53172..82131a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: env: - ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:${{github.action}}-${{github.run_id}} + ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:${{github.ref_name}}-${{github.run_id}} jobs: From 3b8faba4b9b8c6f1f8ddeabc82b6985487e5de1f Mon Sep 17 00:00:00 2001 From: Shayan Ghani Date: Sat, 3 May 2025 14:31:35 +0330 Subject: [PATCH 4/4] fix(ci): changed ghcr image name to pr combo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82131a9..ea743c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: env: - ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:${{github.ref_name}}-${{github.run_id}} + ghcr_repo_addr: ghcr.io/shayan-ghani/container-exporter:pr-${{github.run_id}} jobs: