File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed
Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change 1+ name : LocalStack Ephemeral Instance Test
2+ on : pull_request
3+
4+ jobs :
5+ preview-test :
6+ permissions : write-all
7+ name : ' Test ephemeral instance workflow'
8+ runs-on : ubuntu-latest
9+ steps :
10+ - uses : actions/checkout@v3
11+
12+ - name : Deploy Preview
13+ uses : ./preview
14+ with :
15+ localstack-api-key : ${{ secrets.LOCALSTACK_API_KEY }}
16+ github-token : ${{ secrets.GITHUB_TOKEN }}
17+
18+ - name : Shutdown ephemeral instance
19+ uses : ./ephemeral/shutdown
20+ with :
21+ localstack-api-key : ${{ secrets.LOCALSTACK_API_KEY }}
22+ github-token : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1+ name : Shutdown Ephemeral Instance
2+
3+ inputs :
4+ localstack-api-key :
5+ description : ' LocalStack API key used to access the platform api'
6+ required : true
7+ github-token :
8+ description : ' Github token used to create PR comments'
9+ required : true
10+
11+
12+ runs :
13+ using : composite
14+ steps :
15+ - name : Download PR artifact
16+ uses : actions/download-artifact@v3
17+ with :
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 : Shutdown ephemeral instance
26+ shell : bash
27+ run : |
28+ prId=$(<pr-id.txt)
29+ # TODO: make preview_name configurable
30+ previewName=preview-$prId
31+
32+ response=$(curl -X DELETE \
33+ -H 'ls-api-key: ${{ inputs.localstack-api-key }}' \
34+ -H 'authorization: token ${{ inputs.localstack-api-key }}' \
35+ -H 'content-type: application/json' \
36+ https://api.localstack.cloud/v1/previews/$previewName)
37+ if [[ "$response" != "{}" ]]; then
38+ # In case the deletion fails, e.g. if the instance cannot be found, we raise a proper error on the platform
39+ echo "Unable to delete preview environment. API response: $response"
40+ exit 1
41+ fi
42+
43+ - name : Update status comment
44+ uses : actions-cool/maintain-one-comment@v3.1.1
45+ with :
46+ token : ${{ inputs.github-token }}
47+ body : |
48+ The ephemeral instance for the application preview has been shut down
49+ <!-- Sticky Pull Request Comment -->
50+ body-include : ' <!-- Sticky Pull Request Comment -->'
51+ number : ${{ steps.pr.outputs.pr_id }}
You can’t perform that action at this time.
0 commit comments