2020# This workflow does NOT run Terraform — infrastructure is managed by a
2121# dedicated pipeline in mypythonproject1-infra2.
2222#
23- # Secrets (GitHub Environments "staging" and "production"):
23+ # Secrets (GitHub Environments "dev", " staging", and "production"):
2424# AWS_ROLE_TO_ASSUME — OIDC role ARN with ECR push permission
2525# AWS_REGION — e.g. us-east-1
2626# GITOPS_DEPLOY_TOKEN — PAT (contents:write) on mypythonproject1-gitops
27- # ARGOCD_SERVER — ArgoCD server hostname ( no https:// )
27+ # ARGOCD_SERVER — ArgoCD server hostname only, no scheme (e.g. argocd.1.2.3.4.nip.io )
2828# ARGOCD_TOKEN — ArgoCD API token for health poll
2929#
3030# Variables (GitHub Environments):
4646 description : " Target environment"
4747 required : true
4848 type : choice
49- options : [staging, production]
49+ options : [dev, staging, production]
5050 default : staging
5151
5252permissions :
7575 (github.event_name == 'workflow_run'
7676 && github.event.workflow_run.conclusion == 'success')
7777 || (github.event_name == 'workflow_dispatch'
78- && inputs.environment == 'staging ')
79- environment : staging
78+ && inputs.environment == 'dev ')
79+ environment : dev
8080 strategy :
8181 matrix :
8282 service : [backend, frontend]
@@ -133,7 +133,7 @@ jobs:
133133 runs-on : ubuntu-latest
134134 timeout-minutes : 10
135135 needs : [build-dev]
136- environment : staging
136+ environment : dev
137137 permissions :
138138 contents : read
139139 steps :
@@ -167,6 +167,65 @@ jobs:
167167 git commit -m "chore(deploy): dev image tag ${{ steps.tag.outputs.new-tag }} [skip ci]"
168168 git push origin main
169169
170+ # ---------------------------------------------------------------------------
171+ # 0c. Wait for ArgoCD to sync dev and report health
172+ # ---------------------------------------------------------------------------
173+ argocd-sync-dev :
174+ name : " ArgoCD Sync [dev]"
175+ runs-on : ubuntu-latest
176+ timeout-minutes : 15
177+ needs : [update-gitops-dev]
178+ environment : dev
179+ steps :
180+ - name : Poll ArgoCD application health
181+ env :
182+ ARGOCD_SERVER : ${{ secrets.ARGOCD_SERVER }}
183+ ARGOCD_TOKEN : ${{ secrets.ARGOCD_TOKEN }}
184+ run : |
185+ APP="mypythonproject1-dev"
186+ MAX=30 # 30 × 30s = 15 min
187+ SLEEP=30
188+
189+ for i in $(seq 1 $MAX); do
190+ RESP=$(curl -sf \
191+ -H "Authorization: Bearer $ARGOCD_TOKEN" \
192+ "http://${ARGOCD_SERVER}/api/v1/applications/${APP}" || true)
193+
194+ HEALTH=$(echo "$RESP" | jq -r '.status.health.status // "Unknown"')
195+ SYNC=$(echo "$RESP" | jq -r '.status.sync.status // "Unknown"')
196+ echo "[$i/$MAX] health=$HEALTH sync=$SYNC"
197+
198+ if [[ "$HEALTH" == "Healthy" && "$SYNC" == "Synced" ]]; then
199+ echo "✅ ArgoCD: $APP is Healthy and Synced"
200+ exit 0
201+ fi
202+
203+ if [[ "$HEALTH" == "Degraded" ]]; then
204+ echo "❌ ArgoCD: $APP health is Degraded — failing fast"
205+ exit 1
206+ fi
207+
208+ sleep $SLEEP
209+ done
210+
211+ echo "❌ Timeout: $APP did not become Healthy+Synced within $((MAX * SLEEP / 60)) min"
212+ exit 1
213+
214+ # ---------------------------------------------------------------------------
215+ # 0d. Smoke test (dev)
216+ # ---------------------------------------------------------------------------
217+ smoke-test-dev :
218+ name : " Smoke Test [dev]"
219+ if : false # disabled until APP_URL is configured after first deploy
220+ needs : [argocd-sync-dev]
221+ uses : ./.github/workflows/_smoke-test.yml
222+ with :
223+ environment : dev
224+ app-url : ${{ vars.APP_URL }}
225+ warmup-seconds : 15
226+ deploy-sha : ${{ github.event.workflow_run.head_sha || github.sha }}
227+ secrets : inherit
228+
170229# ##############################################################################
171230# ─── STAGING ────────────────────────────────────────────────────────────────
172231# ##############################################################################
@@ -179,8 +238,8 @@ jobs:
179238 timeout-minutes : 20
180239 if : >
181240 (github.event_name == 'workflow_run'
182- && github.event.workflow_run.conclusion == 'success')
183- || (github.event_name == 'workflow_dispatch'
241+ && github.event.workflow_run.conclusion == 'success') ||
242+ (github.event_name == 'workflow_dispatch'
184243 && inputs.environment == 'staging')
185244 environment : staging
186245 strategy :
@@ -317,7 +376,7 @@ jobs:
317376 for i in $(seq 1 $MAX); do
318377 RESP=$(curl -sf \
319378 -H "Authorization: Bearer $ARGOCD_TOKEN" \
320- "https ://${ARGOCD_SERVER}/api/v1/applications/${APP}" || true)
379+ "http ://${ARGOCD_SERVER}/api/v1/applications/${APP}" || true)
321380
322381 HEALTH=$(echo "$RESP" | jq -r '.status.health.status // "Unknown"')
323382 SYNC=$(echo "$RESP" | jq -r '.status.sync.status // "Unknown"')
@@ -344,6 +403,7 @@ jobs:
344403 # ---------------------------------------------------------------------------
345404 smoke-test-staging :
346405 name : " Smoke Test [staging]"
406+ if : false # disabled until APP_URL is configured after first deploy
347407 needs : [argocd-sync-staging]
348408 uses : ./.github/workflows/_smoke-test.yml
349409 with :
@@ -403,7 +463,7 @@ jobs:
403463 runs-on : ubuntu-latest
404464 timeout-minutes : 20
405465 if : startsWith(github.ref, 'refs/tags/v')
406- environment : production
466+ environment : prod
407467 strategy :
408468 matrix :
409469 service : [backend, frontend]
@@ -463,7 +523,7 @@ jobs:
463523 runs-on : ubuntu-latest
464524 timeout-minutes : 10
465525 needs : [build-production]
466- environment : production
526+ environment : prod
467527 permissions :
468528 contents : read
469529 steps :
@@ -510,7 +570,7 @@ jobs:
510570 runs-on : ubuntu-latest
511571 timeout-minutes : 20
512572 needs : [update-gitops-production]
513- environment : production
573+ environment : prod
514574 steps :
515575 - name : Poll ArgoCD application health
516576 env :
@@ -524,7 +584,7 @@ jobs:
524584 for i in $(seq 1 $MAX); do
525585 RESP=$(curl -sf \
526586 -H "Authorization: Bearer $ARGOCD_TOKEN" \
527- "https ://${ARGOCD_SERVER}/api/v1/applications/${APP}" || true)
587+ "http ://${ARGOCD_SERVER}/api/v1/applications/${APP}" || true)
528588
529589 HEALTH=$(echo "$RESP" | jq -r '.status.health.status // "Unknown"')
530590 SYNC=$(echo "$RESP" | jq -r '.status.sync.status // "Unknown"')
@@ -551,6 +611,7 @@ jobs:
551611 # ---------------------------------------------------------------------------
552612 smoke-test-production :
553613 name : " Smoke Test [production]"
614+ if : false # disabled until APP_URL is configured after first deploy
554615 needs : [argocd-sync-production]
555616 uses : ./.github/workflows/_smoke-test.yml
556617 with :
0 commit comments