-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (75 loc) · 3 KB
/
deploy-dynamic-env-proxy.yaml
File metadata and controls
87 lines (75 loc) · 3 KB
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
86
87
name: Deploy dynamic PR environment proxy
run-name: Deploy proxy for PR environment on internal-dev by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
build_sandbox:
description: Build sandbox container?
required: false
default: false
type: boolean
permissions:
contents: read
packages: read
jobs:
deploy-pr-proxy:
runs-on: ubuntu-latest
name: Deploy proxy to dynamic PR environment
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install dependencies
uses: ./.github/actions/node-install
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve nodejs version
id: toolversions
run: echo "nodejs_version=$(grep '^nodejs\s' .tool-versions | cut -f2 -d' ')" >>
"$GITHUB_OUTPUT"
- name: "Check if pull request exists for this branch and set
ENVIRONMENT/APIM_ENV"
id: pr_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
echo "Current branch is '$branch_name'"
ENVIRONMENT="internal-dev"
pr_json=$(gh pr list --head "$branch_name" --state open --json number --limit 1)
pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty')
if [[ -n "$pr_number" ]]; then
echo "Pull request exists: #$pr_number"
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
APIM_ENV="$ENVIRONMENT-pr"
# changing environment variable so that PR number is used in proxy pipeline for setting env vars
ENVIRONMENT="pr$pr_number"
else
echo "[ERROR] Pull request $pr_number doesn't exist."
exit 1
fi
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
- name: Build OAS spec
uses: ./.github/actions/build-oas-spec
with:
version: "pr${{ steps.pr_exists.outputs.pr_number }}"
apimEnv: "${{ env.APIM_ENV }}"
buildSandbox: ${{ inputs.build_sandbox }}
nodejs_version: ${{ steps.toolversions.outputs.nodejs_version }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy proxy
env:
PROXYGEN_API_NAME: nhs-notify-supplier
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
uses: ./.github/actions/build-proxies
with:
targetComponent: api
environment: "${{ env.ENVIRONMENT }}"
apimEnv: "${{ env.APIM_ENV }}"
runId: "${{ github.run_id }}"
buildSandbox: ${{ inputs.build_sandbox }}
releaseVersion: ${{ github.ref_name }}
version: "pr${{ steps.pr_exists.outputs.pr_number }}"