Skip to content

Commit 97086a0

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

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/cdk.yml

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