Skip to content

Commit 82749c8

Browse files
committed
add a simple gha workflow for testing cdk deployments
1 parent 26d82ba commit 82749c8

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/cdk.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Deploy using CDK
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'README.md'
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
schedule:
13+
# “At 00:00 on Sunday.”
14+
- cron: "0 0 * * 0"
15+
workflow_dispatch:
16+
17+
jobs:
18+
cdk:
19+
name: Setup infrastructure using CDK
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: 20
29+
30+
- name: Install CDK
31+
run: |
32+
npm install -g aws-cdk-local aws-cdk
33+
cdklocal --version
34+
35+
- name: Install dependencies
36+
run: |
37+
cd cdk
38+
pip3 install -r requirements.txt
39+
40+
- name: Start LocalStack
41+
uses: LocalStack/[email protected]
42+
with:
43+
image-tag: 'latest'
44+
use-pro: 'true'
45+
configuration: DEBUG=1
46+
install-awslocal: 'true'
47+
env:
48+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
49+
50+
- name: Deploy using CDK
51+
run: |
52+
cd cdk && cdklocal bootstrap
53+
cd ..
54+
AWS_CMD=awslocal CDK_CMD=cdklocal bash ./bin/deploy_cdk.sh
55+
56+
- name: List the resources
57+
run: |
58+
awslocal lambda list-functions
59+
awslocal sqs list-queues
60+
awslocal dynamodb list-tables
61+
awslocal s3 ls
62+
63+
- name: Send a Slack notification
64+
if: failure() || github.event_name != 'pull_request'
65+
uses: ravsamhq/notify-slack-action@v2
66+
with:
67+
status: ${{ job.status }}
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
notification_title: "{workflow} has {status_message}"
70+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
71+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
72+
notify_when: "failure"
73+
env:
74+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
75+
76+
- name: Generate a Diagnostic Report
77+
if: failure()
78+
run: |
79+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
80+
81+
- name: Upload the Diagnostic Report
82+
if: failure()
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: diagnose.json.gz
86+
path: ./diagnose.json.gz

0 commit comments

Comments
 (0)