-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (93 loc) · 4.1 KB
/
deploy.yml
File metadata and controls
96 lines (93 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: GitHub CloudFormation Deployment
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on:
push:
workflow_dispatch:
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Configure AWS credentials from Test account
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Deploy
uses: aws-actions/aws-cloudformation-github-deploy@master
with:
name: TestGitHubAction
template: stack.yaml
parameter-overrides: >-
Environment=beta,
AList="value1,value2"
test-long-running:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Configure AWS credentials from Test account
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
role-duration-seconds: 7200
- name: Test long-running stack (70 minutes)
uses: aws-actions/aws-cloudformation-github-deploy@master
with:
name: test-long-running-${{ github.run_number }}-${{ github.run_attempt }}
template: long-running-stack.yaml
capabilities: "CAPABILITY_IAM"
timeout-in-minutes: 90
test-no-execute-changeset:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Configure AWS credentials from Test account
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Cleanup existing stack if present
run: |
STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}"
if aws cloudformation describe-stacks --stack-name $STACK_NAME 2>/dev/null; then
echo "Stack exists, deleting it first..."
aws cloudformation delete-stack --stack-name $STACK_NAME
aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME
fi
- name: Deploy with no-execute-changeset=1 (should create stack in REVIEW_IN_PROGRESS)
uses: aws-actions/aws-cloudformation-github-deploy@master
with:
name: test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}
template: no-execute-changeset-test.yaml
capabilities: "CAPABILITY_IAM"
no-execute-changeset: "1"
- name: Verify stack is in REVIEW_IN_PROGRESS status
run: |
STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}"
echo "Checking stack status after deployment with no-execute-changeset=1..."
STACK_STATUS=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[0].StackStatus' --output text)
echo "Stack status: $STACK_STATUS"
if [ "$STACK_STATUS" = "REVIEW_IN_PROGRESS" ]; then
echo "✅ SUCCESS: Stack is in REVIEW_IN_PROGRESS status as expected"
else
echo "❌ FAILURE: Stack status is $STACK_STATUS, expected REVIEW_IN_PROGRESS"
echo "This indicates the bug is present - the changeset was executed despite no-execute-changeset=1"
exit 1
fi
- name: Cleanup test stack
if: always()
run: |
STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}"
if aws cloudformation describe-stacks --stack-name $STACK_NAME 2>/dev/null; then
aws cloudformation delete-stack --stack-name $STACK_NAME
aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME
echo "Test stack cleaned up successfully"
fi