Fix release job

This commit is contained in:
Zeecka
2026-01-04 19:03:44 +01:00
parent db27459129
commit 0756a91c2e
+26 -5
View File
@@ -6,19 +6,40 @@ on:
- Docker Image CI - Docker Image CI
types: types:
- completed - completed
branches:
- prod # Only triggers for tags in the production branch
jobs: jobs:
deploy: check-and-deploy:
# 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
environment: production environment: production
steps: steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Check if tag is from prod branch
id: check
run: |
TAG_REF="${{ github.event.workflow_run.head_branch }}"
echo "Tag/Branch: $TAG_REF"
# Récupère les branches contenant ce commit
BRANCHES=$(git branch -r --contains ${{ github.event.workflow_run.head_sha }})
echo "Branches containing this commit: $BRANCHES"
if echo "$BRANCHES" | grep -q "origin/prod"; then
echo "is_prod=true" >> $GITHUB_OUTPUT
echo "✅ Tag is from prod branch - will deploy"
else
echo "is_prod=false" >> $GITHUB_OUTPUT
echo "❌ Tag is not from prod branch - skipping deployment"
fi
- name: Deploy to production server - name: Deploy to production server
if: steps.check.outputs.is_prod == 'true'
uses: appleboy/ssh-action@v1.0.3 uses: appleboy/ssh-action@v1.0.3
with: with:
host: ${{ secrets.PROD_SSH_HOST }} host: ${{ secrets.PROD_SSH_HOST }}