Skip to content

Commit 99d412c

Browse files
committed
add action to startup LS and run TF against it
1 parent 3677f62 commit 99d412c

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Deploy on LocalStack
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'README.md'
7+
branches:
8+
- master
9+
pull_request:
10+
branches:
11+
- master
12+
schedule:
13+
# “At 00:00 on Sunday.”
14+
- cron: "0 0 * * 0"
15+
workflow_dispatch:
16+
17+
jobs:
18+
integration-tests:
19+
name: Setup infrastructure using Terraform
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Start LocalStack
23+
run: |
24+
docker pull localstack/localstack:latest
25+
# Start LocalStack in the background
26+
LS_LOG=trace localstack start -d
27+
# Wait 30 seconds for the LocalStack container to become ready before timing out
28+
echo "Waiting for LocalStack startup..."
29+
localstack wait -t 15
30+
echo "Startup complete"
31+
32+
- name: Run Terraform Config File
33+
run: |
34+
cd terraform
35+
bash run-tflocal.sh
36+
37+
# - name: curl endpoint
38+
# run: |
39+
# rest_api=$(awslocal apigateway get-rest-apis | jq -r '.items[0].id')
40+
# url="https://${rest_api}.execute-api.localhost.localstack.cloud:4566/local/upload"
41+
# echo "curling $url ..."
42+
# result=$(curl $url)
43+
# if [[ "$result" != *"<h1>AWS Transcribe Example</h1>"* ]]; then
44+
# echo "unexpected response"
45+
# echo $result
46+
# exit 1
47+
# fi
48+
49+
- name: Send a Slack notification
50+
if: failure() || github.event_name != 'pull_request'
51+
uses: ravsamhq/notify-slack-action@v2
52+
with:
53+
status: ${{ job.status }}
54+
token: ${{ secrets.GITHUB_TOKEN }}
55+
notification_title: "{workflow} has {status_message}"
56+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
57+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
58+
notify_when: "failure"
59+
env:
60+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
61+
62+
- name: Generate a Diagnostic Report
63+
if: failure()
64+
run: |
65+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
66+
67+
- name: Upload the Diagnostic Report
68+
if: failure()
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: diagnose.json.gz
72+
path: ./diagnose.json.gz

terraform/run-tflocal.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tflocal init
2+
tflocal plan
3+
tflocal apply --auto-approve

0 commit comments

Comments
 (0)