Skip to content

Commit 4a1f865

Browse files
authored
Add configurations for LocalStack CI integration (#3)
* add additional GH actions for PR integration and comments * add input for github_token secret * call prepare/finish directly in main action * minor enhancements
1 parent ae7f8b6 commit 4a1f865

File tree

3 files changed

+89
-6
lines changed

3 files changed

+89
-6
lines changed

action.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,47 @@ inputs:
2323
description: 'Configuration variables to use for LocalStack'
2424
required: false
2525
default: ''
26+
ci-project:
27+
description: 'Name of the CI project to track in LocalStack Cloud'
28+
required: false
29+
default: ''
30+
github-token:
31+
description: 'Github token used to create PR comments'
32+
required: false
33+
default: ''
2634

2735
runs:
2836
using: "composite"
2937
steps:
30-
-
38+
- name: Initial PR comment
39+
# TODO: potentially replace with Action version number over time
40+
uses: LocalStack/setup-localstack/prepare@main
41+
if: inputs.ci-project && inputs.github-token
42+
with:
43+
github-token: ${{ inputs.github-token }}
44+
ci-project: ${{ inputs.ci-project }}
45+
46+
- name: Start LocalStack
3147
run: |
3248
pip install pyopenssl -U
3349
3450
if [ "$USE_PRO" = true ]; then
35-
docker pull localstack/localstack-pro:"$IMAGE_TAG"
51+
docker pull localstack/localstack-pro:"$IMAGE_TAG" &
3652
CONFIGURATION="$CONFIGURATION DNS_ADDRESS=0"
3753
else
38-
docker pull localstack/localstack:"$IMAGE_TAG"
54+
docker pull localstack/localstack:"$IMAGE_TAG" &
3955
fi
4056
4157
pip install localstack
42-
eval "${CONFIGURATION} localstack start -d"
43-
44-
localstack wait -t 30
4558
if [ "$INSTALL_AWSLOCAL" = true ]; then
4659
pip install awscli-local[ver1]
4760
fi
61+
62+
export CI_PROJECT=${{ inputs.ci-project }}
63+
eval "${CONFIGURATION} localstack start -d"
64+
65+
localstack wait -t 30
66+
4867
shell: bash
4968
env:
5069
IMAGE_TAG: "${{ inputs.image-tag }}"

finish/action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Finish CI Build
2+
3+
inputs:
4+
github-token:
5+
description: 'Github token used to create PR comments'
6+
required: true
7+
ci-project:
8+
description: 'Name of the CI project to track in LocalStack Cloud'
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Download PR artifact
15+
uses: dawidd6/action-download-artifact@v2
16+
with:
17+
workflow: ${{ github.event.workflow_run.workflow_id }}
18+
name: pr
19+
20+
- name: Load the PR ID
21+
id: pr
22+
shell: bash
23+
run: echo "pr_id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
24+
25+
- name: Update status comment
26+
uses: actions-cool/maintain-one-comment@v3.1.1
27+
with:
28+
token: ${{ inputs.github-token }}
29+
body: |
30+
🚀 LocalStack Stack Insights and Cloud Pod state for this CI run: https://app.localstack.cloud/ci/${{ inputs.ci-project }}
31+
<!-- Sticky Pull Request Comment -->
32+
body-include: '<!-- Sticky Pull Request Comment -->'
33+
number: ${{ steps.pr.outputs.pr_id }}

prepare/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Start CI Build
2+
3+
inputs:
4+
github-token:
5+
description: 'Github token used to create PR comments'
6+
required: true
7+
ci-project:
8+
description: 'Name of the CI project to track in LocalStack Cloud'
9+
required: false
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Save PR number
15+
shell: bash
16+
run: echo ${{ github.event.number }} > ./pr-id.txt
17+
18+
- name: Upload PR number
19+
uses: actions/upload-artifact@v3
20+
with:
21+
name: pr
22+
path: ./pr-id.txt
23+
24+
- name: Create initial PR comment
25+
uses: actions-cool/maintain-one-comment@v3.1.1
26+
with:
27+
token: ${{ inputs.github-token }}
28+
body: |
29+
⚡️ Running CI build with LocalStack ...
30+
<!-- Sticky Pull Request Comment -->
31+
body-include: '<!-- Sticky Pull Request Comment -->'

0 commit comments

Comments
 (0)