Skip to content

Destroy

Destroy #2311

Workflow file for this run

name: Destroy
on: delete
permissions:
id-token: write
jobs:
destroy:
# Protected branches should be designated as such in the GitHub UI.
# So, a protected branch should never have this workflow run, since the branch should never be deleted.
# This conditional is a backup mechanism to help prevent mistakes from becoming disasters.
# This is a list of branch names that are commonly used for protected branches/environments.
# Add/remove names from this list as appropriate.
if: github.event.ref_type == 'branch' && !contains(fromJson('["develop", "main", "master", "impl", "val", "prod", "production"]'), github.event.ref)
environment: dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set stage_name
run: |
echo "stage_name=$(./scripts/stage_name_for_branch.sh ${{ github.event.ref }})" >> $GITHUB_ENV
- name: Setup env
uses: ./.github/actions/setup_env
- name: build scripts
shell: bash
run: |
npx lerna run build:ci-scripts
- name: lock this branch to prevent concurrent destroys
run: ./.github/github-lock.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get AWS credentials
uses: ./.github/actions/get_aws_credentials
with:
region: ${{ vars.AWS_DEFAULT_REGION }}
account-id: ${{ secrets.DEV_AWS_ACCOUNT_ID }}
stage-name: main
- name: destroy all
env:
STAGE_PREFIX: ${{ secrets.STAGE_PREFIX }}
run: node ./scripts/destroy_stage.js $stage_name
- name: Alert Slack On Destroy Failure
uses: rtCamp/action-slack-notify@v2
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: Destroy Alerts
SLACK_ICON_EMOJI: ':bell:'
SLACK_COLOR: ${{job.status}}
SLACK_FOOTER: ''
MSG_MINIMAL: actions url,commit,ref
otel-export-trace:
if: always()
name: OpenTelemetry Export Trace
runs-on: ubuntu-latest
needs: [destroy] # must run when all jobs are complete
steps:
- name: Export Workflow Trace
uses: inception-health/otel-export-trace-action@latest
env:
NR_LICENSE_KEY: ${{ secrets.NR_LICENSE_KEY }}}
with:
otlpEndpoint: https://gov-otlp.nr-data.net:4317
otlpHeaders: 'api-key: $NR_LICENSE_KEY'
githubToken: ${{ secrets.GITHUB_TOKEN }}