From bfbe32779838ba6749060cf63ace24462d3fea1f Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 18:31:44 +0100 Subject: [PATCH 1/3] Fix release job --- .github/workflows/releases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 561cabc..bada2f7 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -10,7 +10,7 @@ jobs: docker-releases: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') + if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') steps: - name: Get release version From 7ac118168be0b38a72f469d1a470002164e2489a Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 18:42:37 +0100 Subject: [PATCH 2/3] Fix release job --- .github/workflows/releases.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index bada2f7..139bfec 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -10,7 +10,6 @@ jobs: docker-releases: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') steps: - name: Get release version From adcab6da0205b5ee7f93daa8ccaf851acf0331e5 Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 18:49:53 +0100 Subject: [PATCH 3/3] Fix release job --- .github/workflows/deployement.yml | 4 ++- .github/workflows/releases.yml | 51 ++++++++++++++++++------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/deployement.yml b/.github/workflows/deployement.yml index 2cdfaf3..cb0efdc 100644 --- a/.github/workflows/deployement.yml +++ b/.github/workflows/deployement.yml @@ -6,10 +6,12 @@ on: - Docker Image CI types: - completed + branches: + - prod # Only triggers for tags in the production branch jobs: deploy: - # ne déploie que si le build a réussi + # Deploys only if the build was successfuli if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 139bfec..cd82718 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -3,23 +3,40 @@ name: Docker Image CI on: push: tags: - - '*' + - '*' jobs: - docker-releases: - runs-on: ubuntu-latest steps: - name: Get release version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - name: downcase username + - name: Downcase username run: echo "lower_actor=${GITHUB_ACTOR,,}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 # required to verify branch + + - name: Check which branch the tag belongs to + id: check_branch + run: | + # Trouve les branches qui contiennent ce tag + BRANCHES=$(git branch -r --contains ${{ github.ref }}) + + if echo "$BRANCHES" | grep -q "origin/main"; then + echo "branch=main" >> $GITHUB_OUTPUT + echo "LATEST_TAG=latest" >> $GITHUB_ENV + elif echo "$BRANCHES" | grep -q "origin/prod"; then + echo "branch=prod" >> $GITHUB_OUTPUT + echo "LATEST_TAG=latest-prod" >> $GITHUB_ENV + else + echo "branch=other" >> $GITHUB_OUTPUT + echo "LATEST_TAG=" >> $GITHUB_ENV + fi - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -30,25 +47,15 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Determine latest tag - run: | - if [[ "${GITHUB_REF_NAME}" == "main" ]]; then - echo "LATEST_TAG=latest" >> $GITHUB_ENV - elif [[ "${GITHUB_REF_NAME}" == "prod" ]]; then - echo "LATEST_TAG=latest-prod" >> $GITHUB_ENV - else - echo "LATEST_TAG=" >> $GITHUB_ENV - fi + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker images uses: docker/build-push-action@v6.9.0 with: - context: ./ - push: true - tags: | - ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} - ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.LATEST_TAG }} + context: ./ + push: true + tags: | + ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} + ${{ env.LATEST_TAG && format('ghcr.io/{0}/aperisolve:{1}', env.lower_actor, env.LATEST_TAG) || '' }}