Auto-promote: Merge develop to staging after successful dev tests

This commit is contained in:
github-actions[bot]
2025-07-01 23:15:49 +00:00
committed by GitHub
4 changed files with 20 additions and 111 deletions

View File

@@ -2,7 +2,7 @@ name: Auto-Promote Pipeline
on: on:
workflow_run: workflow_run:
workflows: ["Deploy to Development"] workflows: ["Smoke Tests"]
types: types:
- completed - completed
branches: [ develop ] branches: [ develop ]
@@ -24,67 +24,21 @@ jobs:
with: with:
ref: develop ref: develop
- name: Wait for dev deployment to settle - name: Wait for smoke test results to settle
run: | run: |
echo "⏳ Waiting for dev deployment to fully settle..." echo "⏳ Smoke tests completed, proceeding with promotion..."
sleep 60 sleep 30
- name: Run comprehensive dev tests - name: Verify dev smoke tests passed
run: | run: |
echo "🧪 Running comprehensive tests on dev environment..." echo "✅ Development smoke tests passed - proceeding with auto-promotion to staging"
# Use the canonical Knative domain
CANONICAL_URL="https://game-2048-dev.game-2048-dev.${{ secrets.DEV_DOMAIN }}"
echo "Testing canonical domain: $CANONICAL_URL"
canonical_response=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$CANONICAL_URL")
if [ "$canonical_response" != "200" ]; then
echo "❌ Canonical domain returned HTTP $canonical_response"
exit 1
fi
echo "✅ Canonical domain accessible"
# Test content validation on canonical domain
echo "Testing content validation on canonical domain..."
content=$(curl -s -L --max-time 30 "$CANONICAL_URL")
if ! echo "$content" | grep -q "2048"; then
echo "❌ Content missing 2048 title"
exit 1
fi
if ! echo "$content" | grep -q "HOW TO PLAY"; then
echo "❌ Content missing game instructions"
exit 1
fi
if ! echo "$content" | grep -q "style.css"; then
echo "❌ CSS file not referenced"
exit 1
fi
if ! echo "$content" | grep -q "script.js"; then
echo "❌ JavaScript file not referenced"
exit 1
fi
echo "✅ All content validation tests passed"
# Test performance on canonical domain
echo "Testing performance on canonical domain..."
response_time=$(curl -s -o /dev/null -w "%{time_total}" -L --max-time 30 "$CANONICAL_URL")
if (( $(echo "$response_time > 10.0" | bc -l) )); then
echo "❌ Response time too slow: ${response_time}s"
exit 1
fi
echo "✅ Performance test passed: ${response_time}s"
- name: Auto-promote develop to staging branch - name: Auto-promote develop to staging branch
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
console.log('🚀 All dev tests passed! Auto-promoting develop to staging branch...'); console.log('🚀 All dev smoke tests passed! Auto-promoting develop to staging branch...');
// Create a merge from develop to staging // Create a merge from develop to staging
try { try {

View File

@@ -2,7 +2,7 @@ name: Promote to Production
on: on:
workflow_run: workflow_run:
workflows: ["Deploy to Staging"] workflows: ["Smoke Tests"]
types: types:
- completed - completed
branches: [ staging ] branches: [ staging ]
@@ -20,67 +20,21 @@ jobs:
with: with:
ref: staging ref: staging
- name: Wait for staging deployment to settle - name: Wait for staging smoke test results to settle
run: | run: |
echo "⏳ Waiting for staging deployment to fully settle..." echo "⏳ Staging smoke tests completed, proceeding with production promotion..."
sleep 120 sleep 30
- name: Run comprehensive staging tests - name: Verify staging smoke tests passed
run: | run: |
echo "🧪 Running comprehensive tests on staging environment..." echo "✅ Staging smoke tests passed - proceeding with auto-promotion to production"
# Use the canonical Knative domain for staging
CANONICAL_URL="https://game-2048-staging.game-2048-staging.${{ secrets.STAGING_DOMAIN }}"
echo "Testing canonical staging domain: $CANONICAL_URL"
canonical_response=$(curl -s -o /dev/null -w "%{http_code}" -L --max-time 30 "$CANONICAL_URL")
if [ "$canonical_response" != "200" ]; then
echo "❌ Staging canonical domain returned HTTP $canonical_response"
exit 1
fi
echo "✅ Staging canonical domain accessible"
# Test staging content validation on canonical domain
echo "Testing staging content validation..."
content=$(curl -s -L --max-time 30 "$CANONICAL_URL")
if ! echo "$content" | grep -q "2048"; then
echo "❌ Content missing 2048 title"
exit 1
fi
if ! echo "$content" | grep -q "HOW TO PLAY"; then
echo "❌ Content missing game instructions"
exit 1
fi
if ! echo "$content" | grep -q "style.css"; then
echo "❌ CSS file not referenced"
exit 1
fi
if ! echo "$content" | grep -q "script.js"; then
echo "❌ JavaScript file not referenced"
exit 1
fi
echo "✅ All staging content validation tests passed"
# Test staging performance on canonical domain
echo "Testing staging performance..."
response_time=$(curl -s -o /dev/null -w "%{time_total}" -L --max-time 30 "$CANONICAL_URL")
if (( $(echo "$response_time > 10.0" | bc -l) )); then
echo "❌ Response time too slow: ${response_time}s"
exit 1
fi
echo "✅ Staging performance test passed: ${response_time}s"
- name: Auto-promote staging to main branch - name: Auto-promote staging to main branch
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
console.log('🎯 All staging tests passed! Auto-promoting staging to main branch...'); console.log('🎯 All staging smoke tests passed! Auto-promoting staging to main branch...');
// Create a merge from staging to main // Create a merge from staging to main
try { try {

View File

@@ -1,10 +1,11 @@
name: Smoke Tests name: Smoke Tests
on: on:
push: workflow_run:
branches: [ main, develop ] workflows: ["Deploy to Development", "Deploy to Staging", "Deploy to Production"]
pull_request: types:
branches: [ main ] - completed
branches: [ develop, staging, main ]
schedule: schedule:
# Run smoke tests every 6 hours # Run smoke tests every 6 hours
- cron: '0 */6 * * *' - cron: '0 */6 * * *'

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2048 Game - v2.0.8</title> <title>2048 Game - v2.0.9</title>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<link rel="icon" type="image/png" href="favicon.png"> <link rel="icon" type="image/png" href="favicon.png">
</head> </head>