Skip to content

Commit 1ac2600

Browse files
varunr89claude
andcommitted
feat(ci): enable auto-build for execution-traceability and preview/* branches
- Add execution-traceability and preview/** branches to workflow triggers - Implement dynamic image tagging based on branch name - Update concurrency group to use github.ref for branch isolation - Add branch-specific build summaries with deployment instructions Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 0331e24 commit 1ac2600

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Docker Image
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, execution-traceability, 'preview/**']
66
schedule:
77
- cron: '0 2 * * 0' # Weekly rebuild (Sunday 2am UTC) for base image security patches
88
workflow_dispatch: # Manual trigger option
@@ -13,7 +13,7 @@ env:
1313

1414
# Prevent overlapping deployments
1515
concurrency:
16-
group: deploy-main
16+
group: deploy-${{ github.ref }}
1717
cancel-in-progress: true
1818

1919
jobs:
@@ -37,14 +37,39 @@ jobs:
3737
- name: Set up Docker Buildx
3838
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
3939

40+
- name: Determine image tag
41+
id: tag
42+
run: |
43+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
44+
TAG="latest"
45+
BRANCH_TAG="main-${{ github.sha }}"
46+
elif [[ "${{ github.ref }}" == "refs/heads/execution-traceability" ]]; then
47+
TAG="execution-traceability"
48+
BRANCH_TAG="execution-traceability-${{ github.sha }}"
49+
elif [[ "${{ github.ref }}" =~ ^refs/heads/preview/ ]]; then
50+
# Extract branch name from refs/heads/preview/feature-name -> feature-name
51+
BRANCH_NAME="${{ github.ref }}"
52+
BRANCH_NAME="${BRANCH_NAME#refs/heads/preview/}"
53+
TAG="preview-${BRANCH_NAME}"
54+
BRANCH_TAG="preview-${BRANCH_NAME}-${{ github.sha }}"
55+
else
56+
# For other branches (manual workflow_dispatch), use branch name
57+
BRANCH_NAME="${{ github.ref_name }}"
58+
TAG="${BRANCH_NAME}"
59+
BRANCH_TAG="${BRANCH_NAME}-${{ github.sha }}"
60+
fi
61+
62+
echo "TAG=${TAG}" >> $GITHUB_OUTPUT
63+
echo "BRANCH_TAG=${BRANCH_TAG}" >> $GITHUB_OUTPUT
64+
4065
- name: Extract metadata
4166
id: meta
4267
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
4368
with:
4469
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4570
tags: |
46-
type=sha,prefix={{branch}}-
47-
type=raw,value=latest
71+
type=raw,value=${{ steps.tag.outputs.TAG }}
72+
type=raw,value=${{ steps.tag.outputs.BRANCH_TAG }}
4873
4974
- name: Build and push Docker image
5075
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
@@ -60,10 +85,15 @@ jobs:
6085
run: |
6186
echo "✅ Docker image built and pushed successfully"
6287
echo ""
63-
echo "📦 Image: ghcr.io/${{ github.repository }}:latest"
64-
echo ""
65-
echo "🚀 To deploy, run locally:"
66-
echo " ./scripts/deploy.sh"
88+
echo "📦 Images:"
89+
echo " ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}"
90+
echo " ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.BRANCH_TAG }}"
6791
echo ""
68-
echo "⚡ Or for quick deploy:"
69-
echo " ./scripts/quick-deploy.sh"
92+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
93+
echo "🚀 To deploy production, run:"
94+
echo " ./scripts/deploy.sh"
95+
else
96+
BRANCH_NAME="${{ github.ref_name }}"
97+
echo "🧪 To deploy preview, add to docker-compose.yml:"
98+
echo " image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}"
99+
fi

0 commit comments

Comments
 (0)