mirror of
https://github.com/ghndrx/k8s-game-2048.git
synced 2026-02-10 06:45:07 +00:00
🚀 **New Branching Strategy:** - develop → triggers dev deployment → auto-promotes to staging branch - staging → triggers staging deployment → manual approval → promotes to main branch - main → triggers production deployment 📝 **Workflow Changes:** - deploy-dev.yml: Now triggers on develop branch - deploy-staging.yml: Now triggers on staging branch push - deploy-prod.yml: Now triggers on main branch push - auto-promote.yml: Tests dev → merges develop to staging branch - promote-to-production.yml: Tests staging → requires approval → merges staging to main - build-image.yml: Now builds on all branches (main, develop, staging) 🎯 **Auto-Promotion Flow:** 1. Push to develop → Deploy to dev → Test → Auto-merge to staging 2. Staging deployment → Test → Manual approval → Auto-merge to main 3. Main deployment → Production live! This provides proper separation between environments with appropriate gates.
65 lines
2.2 KiB
YAML
65 lines
2.2 KiB
YAML
name: Build and Push Container Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop, staging ]
|
|
pull_request:
|
|
branches: [ main, develop, staging ]
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: ghndrx/k8s-game-2048
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=sha,prefix={{branch}}-
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push container image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Create build summary
|
|
run: |
|
|
echo "## 📦 Container Image Build Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Registry | ${{ env.REGISTRY }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Image | ${{ env.IMAGE_NAME }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Tags | $(echo '${{ steps.meta.outputs.tags }}' | tr '\n' ', ') |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Trigger | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
|
|
echo "- 🧪 Development deployment will trigger automatically" >> $GITHUB_STEP_SUMMARY
|
|
echo "- 🎭 [Deploy to staging manually](https://github.com/${{ github.repository }}/actions/workflows/deploy-staging.yml)" >> $GITHUB_STEP_SUMMARY
|
|
echo "- 🚀 [Deploy to production manually](https://github.com/${{ github.repository }}/actions/workflows/deploy-prod.yml)" >> $GITHUB_STEP_SUMMARY
|