mirror of
https://github.com/ghndrx/k8s-game-2048.git
synced 2026-02-10 06:45:07 +00:00
- Change smoke tests to trigger after deployments complete (not on push) - Auto-promotion now depends on smoke test success (not duplicate testing) - Promotion to production depends on staging smoke tests - Eliminates testing previous deployments instead of new ones - Creates logical flow: deploy → test → promote
92 lines
3.9 KiB
YAML
92 lines
3.9 KiB
YAML
name: Promote to Production
|
||
|
||
on:
|
||
workflow_run:
|
||
workflows: ["Smoke Tests"]
|
||
types:
|
||
- completed
|
||
branches: [ staging ]
|
||
|
||
jobs:
|
||
test-staging-and-promote-to-main:
|
||
name: Test Staging and Promote to Main
|
||
runs-on: ubuntu-latest
|
||
environment: staging
|
||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||
|
||
steps:
|
||
- name: Checkout repository
|
||
uses: actions/checkout@v4
|
||
with:
|
||
ref: staging
|
||
|
||
- name: Wait for staging smoke test results to settle
|
||
run: |
|
||
echo "⏳ Staging smoke tests completed, proceeding with production promotion..."
|
||
sleep 30
|
||
|
||
- name: Verify staging smoke tests passed
|
||
run: |
|
||
echo "✅ Staging smoke tests passed - proceeding with auto-promotion to production"
|
||
|
||
- name: Auto-promote staging to main branch
|
||
uses: actions/github-script@v7
|
||
with:
|
||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||
script: |
|
||
console.log('🎯 All staging smoke tests passed! Auto-promoting staging to main branch...');
|
||
|
||
// Create a merge from staging to main
|
||
try {
|
||
const response = await github.rest.repos.merge({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
base: 'main',
|
||
head: 'staging',
|
||
commit_message: 'Auto-promote: Merge staging to main after successful staging tests - Deploy to Production'
|
||
});
|
||
|
||
console.log('✅ Successfully merged staging to main branch');
|
||
console.log('This will trigger production deployment automatically');
|
||
|
||
return response;
|
||
} catch (error) {
|
||
if (error.status === 409) {
|
||
console.log('ℹ️ No new commits to merge - main is already up to date');
|
||
} else {
|
||
throw error;
|
||
}
|
||
}
|
||
|
||
- name: Create production promotion summary
|
||
run: |
|
||
echo "## 🎉 Production Promotion Summary (Staging → Main)" >> $GITHUB_STEP_SUMMARY
|
||
echo "" >> $GITHUB_STEP_SUMMARY
|
||
echo "| Stage | Status | Action |" >> $GITHUB_STEP_SUMMARY
|
||
echo "|-------|--------|--------|" >> $GITHUB_STEP_SUMMARY
|
||
echo "| Staging Tests | ✅ Passed | Comprehensive validation completed |" >> $GITHUB_STEP_SUMMARY
|
||
echo "| Main Branch | 🚀 Updated | Auto-promotion completed |" >> $GITHUB_STEP_SUMMARY
|
||
echo "| Production Deploy | ⏳ Triggered | Deployment will start automatically |" >> $GITHUB_STEP_SUMMARY
|
||
echo "" >> $GITHUB_STEP_SUMMARY
|
||
echo "### 📋 Tests Performed" >> $GITHUB_STEP_SUMMARY
|
||
echo "- Staging canonical domain accessibility" >> $GITHUB_STEP_SUMMARY
|
||
echo "- Staging custom domain accessibility" >> $GITHUB_STEP_SUMMARY
|
||
echo "- Content and functionality validation" >> $GITHUB_STEP_SUMMARY
|
||
echo "- Performance testing" >> $GITHUB_STEP_SUMMARY
|
||
echo "" >> $GITHUB_STEP_SUMMARY
|
||
echo "### 🎮 Deployment Status" >> $GITHUB_STEP_SUMMARY
|
||
|
||
# Use canonical domain format (these are the Knative domains)
|
||
DEV_URL="https://game-2048-dev.game-2048-dev.dev.wa.darknex.us"
|
||
STAGING_URL="https://game-2048-staging.game-2048-staging.staging.wa.darknex.us"
|
||
PROD_URL="https://game-2048-prod.game-2048-prod.wa.darknex.us"
|
||
|
||
echo "- **Development**: ✅ Live at $DEV_URL" >> $GITHUB_STEP_SUMMARY
|
||
echo "- **Staging**: ✅ Live at $STAGING_URL" >> $GITHUB_STEP_SUMMARY
|
||
echo "- **Production**: 🚀 Deploying to $PROD_URL" >> $GITHUB_STEP_SUMMARY
|
||
echo "" >> $GITHUB_STEP_SUMMARY
|
||
echo "### 🔗 Next Steps" >> $GITHUB_STEP_SUMMARY
|
||
echo "- Production deployment will start automatically" >> $GITHUB_STEP_SUMMARY
|
||
echo "- Monitor the production deployment workflow" >> $GITHUB_STEP_SUMMARY
|
||
echo "- All environments will be live with the latest code!" >> $GITHUB_STEP_SUMMARY
|