Skip to content

Commit c2936aa

Browse files
committed
add a github action workflow
1 parent b47a076 commit c2936aa

File tree

4 files changed

+85
-1
lines changed

4 files changed

+85
-1
lines changed

.github/workflows/main.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Deploy on LocalStack
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+
permissions:
18+
contents: write
19+
20+
jobs:
21+
sam:
22+
name: Setup infrastructure using SAM
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
28+
- uses: gautamkrishnar/keepalive-workflow@v1
29+
30+
- name: Setup Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.10'
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v3
37+
with:
38+
node-version: '18'
39+
40+
- name: Setup SAM
41+
uses: aws-actions/setup-sam@v2
42+
with:
43+
use-installer: true
44+
45+
- name: Setup SAM-Local
46+
run: |
47+
pip install aws-sam-cli-local
48+
samlocal --help
49+
50+
- name: Start LocalStack
51+
run: |
52+
pip install localstack
53+
docker pull localstack/localstack-pro:latest
54+
# Start LocalStack in the background
55+
DEBUG=1 localstack start -d
56+
# Wait 30 seconds for the LocalStack container to become ready before timing out
57+
echo "Waiting for LocalStack startup..."
58+
localstack wait -t 15
59+
echo "Startup complete"
60+
env:
61+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
62+
63+
- name: Build the Lambda Layer
64+
run: |
65+
cd function
66+
pip install --target ../package/python -r requirements.txt
67+
68+
- name: Build the SAM app
69+
run: |
70+
samlocal build
71+
72+
- name: Deploy the SAM app
73+
run: |
74+
curl http://localhost:4566/_localstack/info
75+
samlocal deploy --no-confirm-changeset
76+

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ venv/
66

77
# AWS SAM
88
.aws-sam
9-
samconfig.toml
109
out.json
1110

1211
# LocalStack

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
- "127.0.0.1:443:443" # LocalStack HTTPS Gateway (Pro)
1111
environment:
1212
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN}
13+
- LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY}
1314
- DEBUG=1
1415
- LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT=600
1516
volumes:

samconfig.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version = 0.1
2+
[default.deploy.parameters]
3+
stack_name = "sam-app"
4+
resolve_s3 = true
5+
s3_prefix = "sam-app"
6+
region = "us-east-1"
7+
capabilities = "CAPABILITY_IAM"
8+
image_repositories = []

0 commit comments

Comments
 (0)