Skip to content

Commit 341eed3

Browse files
committed
Refactor build steps
1 parent c8a3e39 commit 341eed3

File tree

4 files changed

+90
-59
lines changed

4 files changed

+90
-59
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "Build Proxies"
2+
description: "Build Proxies"
3+
4+
inputs:
5+
apimEnv:
6+
description: "APIM environment"
7+
required: true
8+
buildSandbox:
9+
description: "Whether to build the sandbox OAS spec"
10+
required: false
11+
default: false
12+
nodejs_version:
13+
description: "Node.js version, set by the CI/CD pipeline workflow"
14+
required: true
15+
NODE_AUTH_TOKEN:
16+
description: "Token for access to github package registry"
17+
required: true
18+
19+
runs:
20+
using: composite
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ inputs.nodejs_version }}
28+
registry-url: 'https://npm.pkg.github.com'
29+
30+
- name: "Cache node_modules"
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
**/node_modules
35+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
36+
restore-keys: |
37+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
38+
39+
- name: Npm install
40+
working-directory: .
41+
env:
42+
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
43+
run: npm ci
44+
shell: bash
45+
46+
- name: Build ${{ inputs.apimEnv }} oas
47+
working-directory: .
48+
env:
49+
APIM_ENV: ${{ inputs.apimEnv }}
50+
shell: bash
51+
run: |
52+
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
53+
then
54+
echo "Building sandbox OAS spec"
55+
make build-json-oas-spec APIM_ENV=sandbox
56+
else
57+
echo "Building env specific OAS spec"
58+
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
59+
fi
60+
61+
if [[ $APIM_ENV == *-pr ]]; then
62+
echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
63+
APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')
64+
fi
65+
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
66+
67+
- name: Upload API OAS specification artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
path: "build"
71+
name: api-oas-specification-${{ inputs.version }}

.github/actions/build-proxies/action.yml

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,11 @@ inputs:
2525
description: "Name of the Component to deploy"
2626
required: true
2727
default: 'api'
28-
nodejs_version:
29-
description: "Node.js version, set by the CI/CD pipeline workflow"
30-
required: true
31-
NODE_AUTH_TOKEN:
32-
description: "Token for access to github package registry"
33-
required: true
3428

3529
runs:
3630
using: composite
3731

3832
steps:
39-
- name: Checkout
40-
uses: actions/checkout@v4
41-
- uses: actions/setup-node@v4
42-
with:
43-
node-version: ${{ inputs.nodejs_version }}
44-
registry-url: 'https://npm.pkg.github.com'
45-
46-
- name: "Cache node_modules"
47-
uses: actions/cache@v4
48-
with:
49-
path: |
50-
**/node_modules
51-
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
52-
restore-keys: |
53-
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
54-
55-
- name: Npm install
56-
working-directory: .
57-
env:
58-
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
59-
run: npm ci
60-
shell: bash
61-
6233
- name: Setup Proxy Name and target
6334
shell: bash
6435
run: |
@@ -87,27 +58,6 @@ runs:
8758
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
8859
fi
8960
90-
- name: Build ${{ inputs.apimEnv }} oas
91-
working-directory: .
92-
env:
93-
APIM_ENV: ${{ inputs.apimEnv }}
94-
shell: bash
95-
run: |
96-
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
97-
then
98-
echo "Building sandbox OAS spec"
99-
make build-json-oas-spec APIM_ENV=sandbox
100-
else
101-
echo "Building env specific OAS spec"
102-
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
103-
fi
104-
105-
if [[ $APIM_ENV == *-pr ]]; then
106-
echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
107-
APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')
108-
fi
109-
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
110-
11161
- name: Upload OAS Spec
11262
uses: actions/upload-artifact@v4
11363
with:
@@ -116,6 +66,7 @@ runs:
11666

11767
- name: Trigger deploy proxy
11868
env:
69+
APIM_ENV: ${{ inputs.apimEnv }}
11970
APP_CLIENT_ID: ${{ env.APP_CLIENT_ID }}
12071
APP_PEM_FILE: ${{ env.APP_PEM_FILE }}
12172
shell: bash

.github/actions/build-sdk/action.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ runs:
5555
run: |
5656
make build VERSION="${{ inputs.version }}"
5757
58-
- name: Upload API OAS specification artifact
59-
uses: actions/upload-artifact@v4
60-
with:
61-
path: "build"
62-
name: api-oas-specification-${{ inputs.version }}
63-
6458
- name: Upload html artifact
6559
uses: actions/upload-artifact@v4
6660
with:

.github/workflows/stage-3-build.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,26 @@ jobs:
5555
version: "${{ inputs.version }}"
5656
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757

58+
artefact-oas-spec:
59+
name: "Build OAS spec"
60+
runs-on: ubuntu-latest
61+
needs: [artefact-jekyll-docs]
62+
timeout-minutes: 10
63+
steps:
64+
- name: "Checkout code"
65+
uses: actions/checkout@v5
66+
- name: "Build proxies"
67+
uses: ./.github/actions/build-oas-spec
68+
with:
69+
apimEnv: "internal-dev-sandbox"
70+
buildSandbox: true
71+
nodejs_version: ${{ inputs.nodejs_version }}
72+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
5874
artefact-sdks:
5975
name: "Build SDKs"
6076
runs-on: ubuntu-latest
77+
needs: [artefact-oas-spec]
6178
timeout-minutes: 10
6279
steps:
6380
- name: "Checkout code"
@@ -117,7 +134,7 @@ jobs:
117134
artefact-proxies:
118135
name: "Build proxies"
119136
runs-on: ubuntu-latest
120-
needs: [pr-create-dynamic-environment]
137+
needs: [artefact-oas-spec, pr-create-dynamic-environment]
121138
timeout-minutes: 10
122139
env:
123140
PROXYGEN_API_NAME: nhs-notify-supplier
@@ -136,5 +153,3 @@ jobs:
136153
runId: "${{ github.run_id }}"
137154
buildSandbox: true
138155
releaseVersion: ${{ github.head_ref || github.ref_name }}
139-
nodejs_version: ${{ inputs.nodejs_version }}
140-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)