Skip to content

DRAFT: templates API #732

DRAFT: templates API

DRAFT: templates API #732

name: PR Create Environment
on:
pull_request:
types: [labeled, opened, synchronize, reopened, unlabeled, edited]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
create-dynamic-environment:
name: Create 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-template-management-dev" \
--arg targetComponent "branch" \
--arg terraformAction "apply" \
--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}"