Release/1.9.4 [main] #257
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: Tear down preview environment for pull request | |
on: | |
pull_request: | |
types: | |
- closed | |
# Cancel any in progress since we are shutting down | |
concurrency: | |
cancel-in-progress: true | |
group: "preview-env-manage-${{ github.event.number }}" | |
env: | |
APP_NAME: ${{ github.event.repository.name }} | |
COPILOT_SERVICE: mindlogger-backend | |
AWS_REGION: us-east-1 | |
jobs: | |
destroy-preview-env: | |
name: Destroy preview env | |
uses: ./.github/workflows/destroy-preview-env.yaml | |
with: | |
env-name: "pr-${{ github.event.number }}" | |
env-snake-name: "pr_${{ github.event.number }}" | |
app-name: ${{ github.event.repository.name }} | |
copilot-service: mindlogger-backend | |
secrets: inherit | |
comment-destroy-preview-env: | |
name: Comment on preview env | |
runs-on: ubuntu-latest | |
needs: [ destroy-preview-env ] | |
if: ${{ !cancelled() }} | |
steps: | |
- name: Comment on PR | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
:arrow_right: Preview environment failed to be destroyed | |
reactions: eyes, rocket | |
comment_tag: service-url | |
- name: "Send Slack message on failure" | |
uses: rtCamp/action-slack-notify@v2 | |
if: ${{ !cancelled() && needs.destroy-preview-env.result == 'failure' }} | |
env: | |
SLACK_COLOR: failure | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEST_RESULTS }} | |
SLACK_TITLE: | | |
:rotating_light: Preview Environment Destroy Failed | |
SLACK_MESSAGE: >- | |
Failed to destroy preview environment pr-${{ github.event.number }} for ${{ github.repository }} | |
\n\n | |
:arrow_right: [Action Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
\n\n | |
:label: [Pull Request](${{ github.event.pull_request.html_url || github.event.head_commit.url }}) | |
MSG_MINIMAL: true | |
destroy-database: | |
name: Destroy database | |
uses: ./.github/workflows/drop_db.yaml | |
with: | |
db-name: "mindlogger_backend_pr_${{ github.event.number }}" | |
secrets: inherit | |
on-db-failure: | |
name: Database destroy failed | |
runs-on: ubuntu-latest | |
if: ${{ always() && (needs.destroy_database.result == 'failure' || needs.destroy_database.result == 'timed_out') }} | |
needs: [ destroy-database ] | |
steps: | |
- name: "Send Slack message on failure" | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_COLOR: failure | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEST_RESULTS }} | |
SLACK_TITLE: | | |
:rotating_light: Database Destroy Failed | |
SLACK_MESSAGE: >- | |
Failed to destroy preview environment pr-${{ github.event.number }} for ${{ github.repository }} | |
\n\n | |
:arrow_right: [Action Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
\n\n | |
:label: [Pull Request](${{ github.event.pull_request.html_url || github.event.head_commit.url }}) | |
MSG_MINIMAL: true |