-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmanual-proxy-environment-deploy.yaml
More file actions
97 lines (86 loc) · 3.24 KB
/
manual-proxy-environment-deploy.yaml
File metadata and controls
97 lines (86 loc) · 3.24 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
88
89
90
91
92
93
94
95
96
97
name: Deploy proxy to environment
run-name: Proxygen Deployment for ${{ inputs.proxy_environment }}
on:
workflow_dispatch:
inputs:
proxy_environment:
description: Name of the proxygen environment to deploy to
required: true
type: choice
default: internal-dev
options:
- internal-dev
- int
- prod
build_sandbox:
description: Build sandbox container?
required: false
default: false
type: boolean
permissions:
contents: read
packages: read
jobs:
deploy-environment:
runs-on: ubuntu-latest
name: Deploy to Environment
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: 22
- name: Npm install
uses: ./.github/actions/node-install
with:
node-version: 22
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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'"
if [ -z "${{ inputs.proxy_environment }}" ]; then
ENVIRONMENT="internal-dev"
else
ENVIRONMENT="${{ inputs.proxy_environment }}"
fi
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"
echo "changing environment variable so that PR number is used in proxy pipeline for setting env vars"
ENVIRONMENT="pr$pr_number"
else
echo "Pull request doesn't exist, setting target env to main"
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
echo "pr_number=" >> $GITHUB_OUTPUT
APIM_ENV="$ENVIRONMENT"
ENVIRONMENT="main"
fi
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
- name: "Build OAS spec"
uses: ./.github/actions/build-oas-spec
with:
apimEnv: "${{ env.APIM_ENV }}"
buildSandbox: ${{ inputs.build_sandbox }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Build proxies"
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:
environment: "${{ env.ENVIRONMENT }}"
apimEnv: "${{ env.APIM_ENV }}"
runId: "${{ github.run_id }}"
buildSandbox: ${{ inputs.build_sandbox }}
releaseVersion: ${{ github.ref_name }}