Skip to content

Commit bfc934a

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

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.github/workflows/cdk.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
cd ..
40+
cd frontend
41+
npm i
42+
43+
- name: Start LocalStack
44+
uses: LocalStack/[email protected]
45+
with:
46+
image-tag: 'latest'
47+
use-pro: 'true'
48+
configuration: DEBUG=1
49+
install-awslocal: 'true'
50+
env:
51+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
52+
53+
- name: Deploy using CDK
54+
run: |
55+
cd cdk
56+
cdklocal bootstrap
57+
cd ..
58+
AWS_CMD=awslocal CDK_CMD=cdklocal bash ./bin/deploy_cdk.sh
59+
60+
- name: List the resources
61+
run: |
62+
awslocal lambda list-functions
63+
awslocal sqs list-queues
64+
awslocal dynamodb list-tables
65+
awslocal s3 ls
66+
67+
- name: Send a Slack notification
68+
if: failure() || github.event_name != 'pull_request'
69+
uses: ravsamhq/notify-slack-action@v2
70+
with:
71+
status: ${{ job.status }}
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
notification_title: "{workflow} has {status_message}"
74+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
75+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
76+
notify_when: "failure"
77+
env:
78+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
79+
80+
- name: Generate a Diagnostic Report
81+
if: failure()
82+
run: |
83+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
84+
85+
- name: Upload the Diagnostic Report
86+
if: failure()
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: diagnose.json.gz
90+
path: ./diagnose.json.gz

bin/ephemeral.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CREATE_RESPONSE=$(localstack ephemeral create \
99
--env LAMBDA_KEEPALIVE_MS=7200000 \
1010
--env EXTENSION_AUTO_INSTALL=localstack-extension-mailhog \
1111
--env DISABLE_CUSTOM_CORS_APIGATEWAY=1 \
12+
--env EXTRA_CORS_ALLOWED_ORIGINS='*' \
1213
--env DISABLE_CUSTOM_CORS_S3=1
1314
)
1415

0 commit comments

Comments
 (0)