generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from NHSDigital/CCM-3023_MissingDestroyPipeline
CCM-3023 missing destroy pipeline
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
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}" |