-
Notifications
You must be signed in to change notification settings - Fork 455
52 lines (49 loc) · 1.75 KB
/
test-cloudformation.yaml
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
name: Test - CloudFormation
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
permissions:
id-token: write
contents: read
jobs:
test:
if: github.repository == 'aws-samples/eks-workshop-v2'
name: run-tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set cluster ID
env:
RUN_ID: "${{ github.job }}"
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
CLUSTER_ID=$(echo $RANDOM | md5sum | head -c 8)
echo "Using cluster ID ${CLUSTER_ID}"
echo "CLUSTER_ID=$CLUSTER_ID" >> $GITHUB_ENV
- name: Set branch name
run: echo "TEST_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
- name: Get AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-duration-seconds: 3600
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GithubActionsSession-${{ env.CLUSTER_ID }}
- name: Deploy
id: deploy
env:
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
aws cloudformation deploy --stack-name cfn-test-${CLUSTER_ID}-${TEST_BRANCH} \
--template-file ./lab/cfn/eks-workshop-ide-cfn.yaml \
--parameter-overrides RepositoryRef=${TEST_BRANCH} \
--capabilities CAPABILITY_NAMED_IAM
- name: Cleanup
if: always()
env:
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
aws cloudformation delete-stack --stack-name cfn-test-${CLUSTER_ID}-${TEST_BRANCH}
aws cloudformation wait stack-delete-complete --stack-name cfn-test-${CLUSTER_ID}-${TEST_BRANCH}