57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
name: Test Deploy Logic
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
|
|
jobs:
|
|
test-deploy-check:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check if tag is from prod branch
|
|
id: check
|
|
run: |
|
|
TAG_REF="${GITHUB_REF#refs/tags/}"
|
|
echo "Tag: $TAG_REF"
|
|
echo "Commit SHA: $GITHUB_SHA"
|
|
|
|
# Get branches containing this commit
|
|
BRANCHES=$(git branch -r --contains HEAD)
|
|
echo "Branches containing this commit: $BRANCHES"
|
|
|
|
# Using prod-test for testing (change to origin/prod in production)
|
|
if echo "$BRANCHES" | grep -q "origin/prod-test"; then
|
|
# Additional check: ensure this commit is at the HEAD of prod-test
|
|
# This prevents deployment if the same commit exists on multiple branches
|
|
PROD_HEAD=$(git rev-parse origin/prod-test)
|
|
TAG_COMMIT=$(git rev-parse HEAD)
|
|
|
|
echo "Prod-test HEAD: $PROD_HEAD"
|
|
echo "Tag commit: $TAG_COMMIT"
|
|
|
|
if [ "$PROD_HEAD" = "$TAG_COMMIT" ]; then
|
|
echo "is_prod=true" >> $GITHUB_OUTPUT
|
|
echo "✅ Tag is at prod-test branch HEAD - will deploy"
|
|
else
|
|
echo "is_prod=false" >> $GITHUB_OUTPUT
|
|
echo "⚠️ Commit is on prod-test but not at HEAD - skipping deployment"
|
|
fi
|
|
else
|
|
echo "is_prod=false" >> $GITHUB_OUTPUT
|
|
echo "❌ Tag is not from prod-test branch - skipping deployment"
|
|
fi
|
|
|
|
- name: Would Deploy
|
|
if: steps.check.outputs.is_prod == 'true'
|
|
run: echo "🚀 DEPLOYMENT WOULD HAPPEN HERE"
|
|
|
|
- name: Would Skip
|
|
if: steps.check.outputs.is_prod != 'true'
|
|
run: echo "⏭️ DEPLOYMENT SKIPPED" |