Fix release job

This commit is contained in:
Zeecka
2026-01-04 18:49:53 +01:00
parent 7ac118168b
commit adcab6da02
2 changed files with 32 additions and 23 deletions
+3 -1
View File
@@ -6,10 +6,12 @@ on:
- Docker Image CI - Docker Image CI
types: types:
- completed - completed
branches:
- prod # Only triggers for tags in the production branch
jobs: jobs:
deploy: 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' }} if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
+29 -22
View File
@@ -3,23 +3,40 @@ name: Docker Image CI
on: on:
push: push:
tags: tags:
- '*' - '*'
jobs: jobs:
docker-releases: docker-releases:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Get release version - name: Get release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: downcase username - name: Downcase username
run: echo "lower_actor=${GITHUB_ACTOR,,}" >> $GITHUB_ENV run: echo "lower_actor=${GITHUB_ACTOR,,}" >> $GITHUB_ENV
- name: Checkout - name: Checkout
uses: actions/checkout@v4 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 - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@@ -30,25 +47,15 @@ jobs:
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} 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
- name: Build and push Docker images - name: Build and push Docker images
uses: docker/build-push-action@v6.9.0 uses: docker/build-push-action@v6.9.0
with: with:
context: ./ context: ./
push: true push: true
tags: | tags: |
ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }}
ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.LATEST_TAG }} ${{ env.LATEST_TAG && format('ghcr.io/{0}/aperisolve:{1}', env.lower_actor, env.LATEST_TAG) || '' }}