Skip to content

Commit 2a7761d

Browse files
committed
fix CI
1 parent 46ef918 commit 2a7761d

1 file changed

Lines changed: 63 additions & 5 deletions

File tree

.github/workflows/cd-eks-gitops.yml

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
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
@@ -46,7 +46,7 @@ on:
4646
description: "Target environment"
4747
required: true
4848
type: choice
49-
options: [staging, production]
49+
options: [dev, staging, production]
5050
default: staging
5151

5252
permissions:
@@ -75,8 +75,8 @@ jobs:
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,64 @@ 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+
"https://${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+
needs: [argocd-sync-dev]
220+
uses: ./.github/workflows/_smoke-test.yml
221+
with:
222+
environment: dev
223+
app-url: ${{ vars.APP_URL }}
224+
warmup-seconds: 15
225+
deploy-sha: ${{ github.event.workflow_run.head_sha || github.sha }}
226+
secrets: inherit
227+
170228
###############################################################################
171229
# ─── STAGING ────────────────────────────────────────────────────────────────
172230
###############################################################################

0 commit comments

Comments
 (0)