mirror of
https://github.com/Sea-Haven-Industries/.github.git
synced 2026-10-06 20:31:59 +00:00
Add post-deploy health checks to CD workflows
Verifies stack status after deploy, prints outputs, and runs project-specific scripts/health-check.sh if present.
This commit is contained in:
parent
242d02bd8f
commit
4d2ab6f32e
2 changed files with 53 additions and 0 deletions
27
.github/workflows/cd-cdk.yaml
vendored
27
.github/workflows/cd-cdk.yaml
vendored
|
|
@ -98,3 +98,30 @@ jobs:
|
||||||
- name: CDK deploy
|
- name: CDK deploy
|
||||||
working-directory: ${{ inputs.cdk-dir }}
|
working-directory: ${{ inputs.cdk-dir }}
|
||||||
run: npx -y cdk deploy --all --require-approval never
|
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."
|
||||||
|
|
|
||||||
26
.github/workflows/cd-sam.yaml
vendored
26
.github/workflows/cd-sam.yaml
vendored
|
|
@ -94,3 +94,29 @@ jobs:
|
||||||
--no-fail-on-empty-changeset \
|
--no-fail-on-empty-changeset \
|
||||||
--role-arn ${{ inputs.cfn-role-arn }} \
|
--role-arn ${{ inputs.cfn-role-arn }} \
|
||||||
$PARAMS
|
$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."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue