diff --git a/.github/workflows/ephemeral.yml b/.github/workflows/ephemeral.yml index d2ddff8..35041ad 100644 --- a/.github/workflows/ephemeral.yml +++ b/.github/workflows/ephemeral.yml @@ -18,6 +18,7 @@ jobs: "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, @@ -31,7 +32,7 @@ jobs: awslocal sqs create-queue --queue-name=test-queue echo "Deploy is done." - - name: Assertion step + - name: Assert mailhog is installed run: | sudo apt-get install jq jo response=$(curl ${AWS_ENDPOINT_URL}/_localstack/extensions/list) @@ -44,6 +45,24 @@ jobs: 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 diff --git a/ephemeral/shutdown/action.yml b/ephemeral/shutdown/action.yml index 8a1364c..6b7910b 100644 --- a/ephemeral/shutdown/action.yml +++ b/ephemeral/shutdown/action.yml @@ -13,9 +13,9 @@ runs: using: composite steps: - name: Download PR artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: pr + name: pr-id - name: Load the PR ID id: pr @@ -36,7 +36,7 @@ runs: run: | response=$(curl -X DELETE \ -s -o /dev/null -w "%{http_code}" \ - -H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \ + -H "ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}" \ -H "content-type: application/json" \ https://api.localstack.cloud/v1/compute/instances/$previewName) if [[ "$response" -ne 200 ]]; then diff --git a/ephemeral/startup/action.yml b/ephemeral/startup/action.yml index 3a4d999..5a580b3 100644 --- a/ephemeral/startup/action.yml +++ b/ephemeral/startup/action.yml @@ -51,9 +51,9 @@ runs: } - name: Download PR artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: pr + name: pr-id - name: Setup preview name shell: bash @@ -73,7 +73,7 @@ runs: lifetime="${{ inputs.lifetime }}" list_response=$(curl -X GET \ - -H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \ + -H "ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}" \ -H "content-type: application/json" \ https://api.localstack.cloud/v1/compute/instances) @@ -81,13 +81,13 @@ runs: if [ -n "$instance_exists" ]; then del_response=$(curl -X DELETE \ - -H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \ + -H "ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}" \ -H "content-type: application/json" \ https://api.localstack.cloud/v1/compute/instances/$previewName) fi response=$(curl -X POST -d "{\"instance_name\": \"${previewName}\", \"lifetime\": ${lifetime} ,\"env_vars\": {\"AUTO_LOAD_POD\": \"${autoLoadPod}\", \"EXTENSION_AUTO_INSTALL\": \"${extensionAutoInstall}\"}}"\ - -H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \ + -H "ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}" \ -H "content-type: application/json" \ https://api.localstack.cloud/v1/compute/instances) endpointUrl=$(echo "$response" | jq -r .endpoint_url) @@ -102,9 +102,9 @@ runs: echo "AWS_ENDPOINT_URL=$endpointUrl" >> $GITHUB_ENV - name: Upload preview instance URL - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: pr + name: preview-instance-url path: ./ls-preview-url.txt - name: Run preview deployment @@ -118,7 +118,7 @@ runs: shell: bash run: | log_response=$(curl -X GET \ - -H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \ + -H "ls-api-key: ${LOCALSTACK_AUTH_TOKEN:-${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}}" \ -H "content-type: application/json" \ https://api.localstack.cloud/v1/compute/instances/$previewName/logs) diff --git a/finish/action.yml b/finish/action.yml index c5e2e09..a8e539c 100644 --- a/finish/action.yml +++ b/finish/action.yml @@ -20,17 +20,17 @@ runs: # Try to get pr artifact from current workflow - name: Download current PR artifact id: get-pr-artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 continue-on-error: true with: - name: pr + name: pr-id # If the above fails, try to get the latest pr artifact from the PR related workflows - name: Download latest PR artifact uses: dawidd6/action-download-artifact@v6 if: ${{ steps.get-pr-artifact.outcome == 'failure' }} with: - name: pr + name: pr-id pr: ${{ github.event.pull_request.number }} # Can be ID or workflow file name, if empty falls back to the latest successful run of the current workflow workflow: ${{ env.PR_ARTIFACT_WORKFLOW }} @@ -40,6 +40,23 @@ runs: shell: bash run: echo "pr_id=$(> $GITHUB_OUTPUT + - name: Download preview instance URL + id: get-preview-instance-url-artifact + if: inputs.include-preview + uses: actions/download-artifact@v4 + with: + name: preview-instance-url + + # If the above fails, try to get the latest pr artifact from the PR related workflows + - name: Download latest PR artifact + uses: dawidd6/action-download-artifact@v6 + if: ${{ steps.get-preview-instance-url-artifact.outcome == 'failure' }} + with: + name: preview-instance-url + pr: ${{ github.event.pull_request.number }} + # Can be ID or workflow file name, if empty falls back to the latest successful run of the current workflow + workflow: ${{ env.PR_ARTIFACT_WORKFLOW }} + - name: Load the Ephemeral Instance URL shell: bash if: inputs.include-preview diff --git a/local/action.yml b/local/action.yml index 1705300..e28824d 100644 --- a/local/action.yml +++ b/local/action.yml @@ -17,7 +17,7 @@ runs: - name: Download current workflow's Local State artifact id: get-state-artifact if: ${{ inputs.action == 'load' }} - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 continue-on-error: true with: name: ${{ inputs.name }} @@ -48,7 +48,7 @@ runs: ACTION: "${{ inputs.action }}" - name: Upload LocalStack State - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ inputs.action == 'save' }} with: name: ${{ inputs.name }} diff --git a/prepare/action.yml b/prepare/action.yml index d1276d1..0b48846 100644 --- a/prepare/action.yml +++ b/prepare/action.yml @@ -16,9 +16,9 @@ runs: run: echo ${{ github.event.number }} > ./pr-id.txt - name: Upload PR number - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: pr + name: pr-id path: ./pr-id.txt - name: Create initial PR comment