Skip to content

Commit 61c8987

Browse files
committed
create a cloud pods workflow
1 parent 19adb8e commit 61c8987

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

.github/workflows/cloud-pods.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Create and Test Cloud Pods
2+
3+
on:
4+
schedule:
5+
# At 00:00 on Saturday.
6+
- cron: "0 0 * * 6"
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: write
17+
actions: read
18+
19+
jobs:
20+
create-cloud-pod:
21+
name: Create Cloud Pods
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Nodejs
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: 22
31+
32+
- name: Install dependencies
33+
run: |
34+
make install
35+
36+
- name: Start LocalStack
37+
uses: LocalStack/setup-localstack@main
38+
with:
39+
image-tag: 'latest'
40+
use-pro: 'true'
41+
configuration: LS_LOG=trace
42+
install-awslocal: 'true'
43+
env:
44+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
45+
46+
- name: Deploy the application
47+
env:
48+
AWS_ACCESS_KEY_ID: test
49+
AWS_SECRET_ACCESS_KEY: test
50+
AWS_DEFAULT_REGION: us-east-1
51+
run: |
52+
make build
53+
make bootstrap
54+
make deploy
55+
56+
- name: Create Cloud Pod
57+
env:
58+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
59+
run: |
60+
message="Cloud Pod created: sample-cdk-rds on $(date) with workflow run id: ${{ github.run_id }}"
61+
localstack pod save sample-cdk-rds --visibility public --message "$message"
62+
63+
- name: Show LocalStack Logs
64+
if: always()
65+
run: |
66+
localstack logs
67+
68+
test-cloud-pod:
69+
name: Test Cloud Pod
70+
needs: create-cloud-pod
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout Code
74+
uses: actions/checkout@v4
75+
76+
- name: Setup Nodejs
77+
uses: actions/setup-node@v3
78+
with:
79+
node-version: 22
80+
81+
- name: Start LocalStack
82+
uses: LocalStack/setup-localstack@main
83+
with:
84+
use-pro: 'true'
85+
install-awslocal: 'true'
86+
env:
87+
DEBUG: 1
88+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
89+
90+
- name: Load Cloud Pod
91+
env:
92+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
93+
run: |
94+
localstack pod load sample-cdk-rds
95+
96+
- name: Install dependencies
97+
run: |
98+
npm install
99+
100+
- name: Run Integration Tests
101+
run: |
102+
npm test
103+
104+
- name: Show LocalStack Logs
105+
if: always()
106+
run: |
107+
localstack logs
108+
109+
- name: Send a Slack notification
110+
if: failure() || github.event_name != 'pull_request'
111+
uses: ravsamhq/notify-slack-action@v2
112+
with:
113+
status: ${{ job.status }}
114+
token: ${{ secrets.GITHUB_TOKEN }}
115+
notification_title: "{workflow} has {status_message}"
116+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
117+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
118+
notify_when: "failure"
119+
env:
120+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
121+
122+
- name: Generate a Diagnostic Report
123+
if: failure()
124+
run: |
125+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
126+
127+
- name: Upload the Diagnostic Report
128+
if: failure()
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: diagnose.json.gz
132+
path: ./diagnose.json.gz

0 commit comments

Comments
 (0)