diff --git a/.github/workflows/cd-cdk.yaml b/.github/workflows/cd-cdk.yaml index 65e473b..2aed4c6 100644 --- a/.github/workflows/cd-cdk.yaml +++ b/.github/workflows/cd-cdk.yaml @@ -98,3 +98,30 @@ jobs: - name: CDK deploy working-directory: ${{ inputs.cdk-dir }} run: npx -y cdk deploy --all --require-approval never + + - name: Post-deploy health check + if: ${{ inputs.stack-name != '' }} + run: | + echo "Health check: verifying stack ${{ inputs.stack-name }}..." + + STATUS=$(aws cloudformation describe-stacks \ + --stack-name "${{ inputs.stack-name }}" \ + --query 'Stacks[0].StackStatus' --output text) + if [[ "$STATUS" != *"COMPLETE" ]] || [[ "$STATUS" == *"ROLLBACK"* ]]; then + echo "::error::Stack ${{ inputs.stack-name }} ended in $STATUS after deploy." + exit 1 + fi + echo "Stack status: $STATUS" + + echo "Stack outputs:" + aws cloudformation describe-stacks \ + --stack-name "${{ inputs.stack-name }}" \ + --query 'Stacks[0].Outputs[*].[OutputKey,OutputValue]' --output table + + # Run project-specific health check if it exists + if [[ -f scripts/health-check.sh ]]; then + echo "Running project health check..." + bash scripts/health-check.sh "${{ inputs.stack-name }}" "${{ inputs.region }}" + fi + + echo "Health check passed." diff --git a/.github/workflows/cd-sam.yaml b/.github/workflows/cd-sam.yaml index 713df93..0d8f69f 100644 --- a/.github/workflows/cd-sam.yaml +++ b/.github/workflows/cd-sam.yaml @@ -94,3 +94,29 @@ jobs: --no-fail-on-empty-changeset \ --role-arn ${{ inputs.cfn-role-arn }} \ $PARAMS + + - name: Post-deploy health check + run: | + echo "Health check: verifying stack ${{ inputs.stack-name }}..." + + STATUS=$(aws cloudformation describe-stacks \ + --stack-name "${{ inputs.stack-name }}" \ + --query 'Stacks[0].StackStatus' --output text) + if [[ "$STATUS" != *"COMPLETE" ]] || [[ "$STATUS" == *"ROLLBACK"* ]]; then + echo "::error::Stack ${{ inputs.stack-name }} ended in $STATUS after deploy." + exit 1 + fi + echo "Stack status: $STATUS" + + echo "Stack outputs:" + aws cloudformation describe-stacks \ + --stack-name "${{ inputs.stack-name }}" \ + --query 'Stacks[0].Outputs[*].[OutputKey,OutputValue]' --output table + + # Run project-specific health check if it exists + if [[ -f scripts/health-check.sh ]]; then + echo "Running project health check..." + bash scripts/health-check.sh "${{ inputs.stack-name }}" "${{ inputs.region }}" + fi + + echo "Health check passed."