-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
134 lines (122 loc) · 4.42 KB
/
action.yml
File metadata and controls
134 lines (122 loc) · 4.42 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: "Build Proxies"
description: "Build Proxies"
inputs:
version:
description: "Version number"
required: false
releaseVersion:
description: "Release, tag, branch, or commit ID to be used for deployment"
required: true
environment:
description: "Deployment environment"
required: true
apimEnv:
description: "APIM environment"
required: true
runId:
description: "GitHub Actions run ID to fetch the OAS artifact from"
required: true
buildSandbox:
description: "Whether to build the sandbox OAS spec"
required: false
default: false
targetComponent:
description: "Name of the Component to deploy"
required: true
default: 'api'
nodejs_version:
description: "Node.js version, set by the CI/CD pipeline workflow"
required: true
NODE_AUTH_TOKEN:
description: "Token for access to github package registry"
required: true
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.nodejs_version }}
registry-url: 'https://npm.pkg.github.com'
- name: "Cache node_modules"
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
- name: Npm install
working-directory: .
env:
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
run: npm ci
shell: bash
- name: Setup Proxy Name and target
shell: bash
run: |
ENV="${{ inputs.apimEnv }}"
if [[ "$ENV" == "internal-dev" || "$ENV" == *pr ]]; then
echo "TARGET_DOMAIN=suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
elif [[ "$ENV" == "int" ]]; then
echo "TARGET_DOMAIN=suppliers.nonprod.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
elif [[ "$ENV" == "prod" ]]; then
echo "TARGET_DOMAIN=suppliers.prod.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
else
echo "TARGET_DOMAIN=suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
fi
if [ -z $PR_NUMBER ]
then
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
echo "TARGET=https://main.$TARGET_DOMAIN" >> $GITHUB_ENV
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
else
echo "TARGET=https://pr$PR_NUMBER.$TARGET_DOMAIN" >> $GITHUB_ENV
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
fi
- name: Build ${{ inputs.apimEnv }} oas
working-directory: .
env:
APIM_ENV: ${{ inputs.apimEnv }}
shell: bash
run: |
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
then
echo "Building sandbox OAS spec"
make build-json-oas-spec APIM_ENV=sandbox
else
echo "Building env specific OAS spec"
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
fi
if [[ $APIM_ENV == *-pr ]]; then
echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')
fi
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
- name: Upload OAS Spec
uses: actions/upload-artifact@v4
with:
name: ${{ env.APIM_ENV }}-build-output
path: ./build
- name: Trigger deploy proxy
env:
APP_CLIENT_ID: ${{ env.APP_CLIENT_ID }}
APP_PEM_FILE: ${{ env.APP_PEM_FILE }}
shell: bash
run: |
.github/scripts/dispatch_internal_repo_workflow.sh \
--infraRepoName "nhs-notify-supplier-api" \
--releaseVersion "${{ inputs.releaseVersion }}" \
--targetComponent "${{ inputs.targetComponent }}" \
--targetWorkflow "proxy-deploy.yaml" \
--targetEnvironment "${{ inputs.environment }}" \
--runId "${{ inputs.runId }}" \
--buildSandbox ${{ inputs.buildSandbox }} \
--apimEnvironment "${{ env.APIM_ENV }}" \
--boundedContext "notify-supplier" \
--targetDomain "$TARGET_DOMAIN" \
--version "${{ inputs.version }}"