print logs of ephemeral instance after executing preview-cmd #141
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | |
"skip-ephemeral-stop": "true", | |
"preview-cmd": ${{ toJSON(env.PREVIEW_CMD) }}, | |
"lifetime": 5, | |
"extension-auto-install": "localstack-extension-mailhog", | |
} | |
env: | |
LOCALSTACK_API_KEY: ${{ secrets.STAGING_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: Assertion step | |
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 | |
# 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.STAGING_LOCALSTACK_API_KEY }} | |
GH_ACTION_VERSION: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} |