Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-r-bjss committed Dec 16, 2024
2 parents e79a35a + 234dade commit 12d44e5
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/pr_destroy_dynamic_env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: PR Destroy Environment

on:
pull_request:
types: [closed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
create-dynamic-environment:
name: Destroy Dynamic Environment
runs-on: ubuntu-latest

steps:
- name: Trigger nhs-notify-internal dynamic environment destruction
shell: bash
run: |
set -x
this_repo_name=$(echo ${{ github.repository }} | cut -d'/' -f2)
DISPATCH_EVENT=$(jq -ncM \
--arg infraRepoName "${this_repo_name}" \
--arg releaseVersion "main" \
--arg targetEnvironment "pr${{ github.event.number }}" \
--arg targetAccountGroup "nhs-notify-iam-dev" \
--arg targetComponent "branch" \
--arg terraformAction "destroy" \
--arg overrides "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
'{ "ref": "main",
"inputs": {
"infraRepoName": $infraRepoName,
"releaseVersion", $releaseVersion,
"targetEnvironment", $targetEnvironment,
"targetAccountGroup", $targetAccountGroup,
"targetComponent", $targetComponent,
"terraformAction", $terraformAction,
"overrides", $overrides,
}
}')
curl --fail -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/workflows/dispatch-deploy-dynamic-env.yaml/dispatches \
-d "${DISPATCH_EVENT}"

0 comments on commit 12d44e5

Please sign in to comment.