-
Notifications
You must be signed in to change notification settings - Fork 8
81 lines (74 loc) · 3 KB
/
ephemeral.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: LocalStack Ephemeral Instance Test
on: pull_request
jobs:
preview-test:
permissions: write-all
name: 'Test ephemeral instance workflow'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy Ephemeral Instance
uses: jenseng/dynamic-uses@v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"github-token": ${{ toJSON(secrets.GITHUB_TOKEN) }},
"state-backend": "ephemeral",
"state-action": "start",
"include-preview": "true",
"skip-ephemeral-stop": "true",
"preview-cmd": ${{ toJSON(env.PREVIEW_CMD) }},
"lifetime": 5,
"extension-auto-install": "localstack-extension-mailhog",
}
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
GH_ACTION_VERSION: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
PREVIEW_CMD: |-
awslocal s3 mb s3://test-bucket
awslocal sqs create-queue --queue-name=test-queue
echo "Deploy is done."
- name: Assert mailhog is installed
run: |
sudo apt-get install jq jo
response=$(curl ${AWS_ENDPOINT_URL}/_localstack/extensions/list)
match=$(echo "$response" | jq -r '.[] | select(.distribution.name == "localstack-extension-mailhog") | .distribution.name')
if [ "$match" == "localstack-extension-mailhog" ]; then
echo "Match found: localstack-extension-mailhog"
else
echo "No match found"
echo $response
exit 1
fi
- name: Check PR Comments for preview text
id: check-comments
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
TEXT_TO_FIND="Preview for this PR"
# Fetch PR comments
comments=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments)
# Check if the specific text is in the comments
if echo "$comments" | jq -e --arg text "$TEXT_TO_FIND" '.[] | select(.body | contains($text))' > /dev/null; then
echo "Found the text in PR comments."
else
echo "Text not found in PR comments."
exit 1
fi
env:
GH_TOKEN: ${{ github.token }}
# We want explicit shutdown
- name: Shutdown ephemeral instance
if: ${{ always() }}
uses: jenseng/dynamic-uses@v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"github-token": ${{ toJSON(secrets.GITHUB_TOKEN) }},
"state-backend": "ephemeral",
"state-action": "stop"
}
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
GH_ACTION_VERSION: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}