generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (76 loc) · 3.13 KB
/
pr_merge.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: PR Merged
on:
pull_request:
types: [closed]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
destroy-dynamic-environment:
name: Destroy Dynamic Environment
runs-on: ubuntu-latest
steps:
- name: Trigger nhs-notify-internal dynamic environment workflow
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 "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
--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 -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}"
deploy-main:
name: Deploy changes to main
runs-on: ubuntu-latest
steps:
- name: Trigger nhs-notify-internal static environment workflow deployment
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 "main" \
--arg targetAccountGroup "nhs-notify-iam-dev" \
--arg targetComponent "app" \
--arg terraformAction "apply" \
'{ "ref": "main",
"inputs": {
"infraRepoName": $infraRepoName,
"releaseVersion", $releaseVersion,
"targetEnvironment", $targetEnvironment,
"targetAccountGroup", $targetAccountGroup,
"targetComponent", $targetComponent,
"terraformAction", $terraformAction
}
}')
curl -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-static-env.yaml/dispatches \
-d "${DISPATCH_EVENT}"