Skip to content

Commit 63e104a

Browse files
refactoring other workflows to use reusable deploy
1 parent e748c54 commit 63e104a

4 files changed

Lines changed: 45 additions & 101 deletions

File tree

.github/workflows/deploy-dynamic-env-proxy.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Deploy proxy to environment
2-
run-name: Proxygen Deployment for internal-dev
1+
name: Deploy dynamic PR environment proxy
2+
run-name: Deploy proxy for PR environment on internal-dev by @${{ github.actor }}
33

44
on:
55
workflow_dispatch:
@@ -15,22 +15,23 @@ permissions:
1515
packages: read
1616

1717
jobs:
18-
deploy-environment:
18+
deploy-pr-proxy:
1919
runs-on: ubuntu-latest
20-
name: Deploy to Environment
20+
name: Deploy proxy to dynamic PR environment
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24-
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
25-
with:
26-
node-version: 22
2724

28-
- name: Npm install
25+
- name: Install dependencies
2926
uses: ./.github/actions/node-install
3027
with:
31-
node-version: 22
3228
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3329

30+
- name: Resolve nodejs version
31+
id: toolversions
32+
run: echo "nodejs_version=$(grep '^nodejs\s' .tool-versions | cut -f2 -d' ')" >>
33+
"$GITHUB_OUTPUT"
34+
3435
- name: "Check if pull request exists for this branch and set
3536
ENVIRONMENT/APIM_ENV"
3637
id: pr_exists
@@ -60,23 +61,27 @@ jobs:
6061
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV
6162
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
6263
63-
- name: "Build OAS spec"
64+
- name: Build OAS spec
6465
uses: ./.github/actions/build-oas-spec
6566
with:
67+
version: "pr${{ steps.pr_exists.outputs.pr_number }}"
6668
apimEnv: "${{ env.APIM_ENV }}"
6769
buildSandbox: ${{ inputs.build_sandbox }}
70+
nodejs_version: ${{ steps.toolversions.outputs.nodejs_version }}
6871
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6972

70-
- name: "Build proxies"
73+
- name: Deploy proxy
7174
env:
7275
PROXYGEN_API_NAME: nhs-notify-supplier
7376
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
7477
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
7578
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
7679
uses: ./.github/actions/build-proxies
7780
with:
81+
targetComponent: api
7882
environment: "${{ env.ENVIRONMENT }}"
7983
apimEnv: "${{ env.APIM_ENV }}"
8084
runId: "${{ github.run_id }}"
8185
buildSandbox: ${{ inputs.build_sandbox }}
8286
releaseVersion: ${{ github.ref_name }}
87+
version: "pr${{ steps.pr_exists.outputs.pr_number }}"

.github/workflows/deploy-supplier-api.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ jobs:
231231
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
232232
uses: ./.github/actions/build-proxies
233233
with:
234-
targetComponent: api
235234
environment: ${{ needs.validate.outputs.target_environment }}
236235
apimEnv: ${{ needs.validate.outputs.apim_environment }}
237236
runId: "${{ github.run_id }}"

.github/workflows/pr_closed.yaml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: PR Closed
33
on:
44
workflow_dispatch:
55
pull_request:
6-
types: [closed]
6+
types: [ closed ]
77
branches:
88
- main
99

@@ -34,33 +34,15 @@ jobs:
3434
deploy-main:
3535
needs: check-merge-or-workflow-dispatch
3636
name: Deploy changes to main in dev AWS account
37-
runs-on: ubuntu-latest
3837
if: needs.check-merge-or-workflow-dispatch.outputs.deploy == 'true'
39-
40-
permissions:
41-
id-token: write
42-
contents: read
43-
44-
strategy:
45-
max-parallel: 1
46-
matrix:
47-
component: [api]
48-
49-
steps:
50-
- name: Checkout repository
51-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
52-
- name: Updating Main Environment
53-
env:
54-
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
55-
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
56-
run: |
57-
bash .github/scripts/dispatch_internal_repo_workflow.sh \
58-
--releaseVersion "main" \
59-
--targetWorkflow "dispatch-deploy-static-notify-supplier-api-env.yaml" \
60-
--targetEnvironment "main" \
61-
--targetAccountGroup "nhs-notify-supplier-api-dev" \
62-
--targetComponent "${{ matrix.component }}" \
63-
--terraformAction "apply"
38+
uses: ./.github/workflows/deploy-supplier-api.yaml
39+
secrets: inherit
40+
with:
41+
source_type: branch
42+
source_value: main
43+
deploy_backend: true
44+
backend_account_group: dev
45+
deploy_proxy: false
6446

6547
check-event-schemas-version-change:
6648
name: Check for event schemas package version change
@@ -78,8 +60,8 @@ jobs:
7860
- name: Setup NodeJS
7961
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
8062
with:
81-
node-version-file: '.tool-versions'
82-
registry-url: 'https://npm.pkg.github.com'
63+
node-version-file: ".tool-versions"
64+
registry-url: "https://npm.pkg.github.com"
8365

8466
- name: check if local version differs from latest published version
8567
id: check-version
@@ -137,8 +119,8 @@ jobs:
137119
- name: Setup NodeJS
138120
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
139121
with:
140-
node-version-file: '.tool-versions'
141-
registry-url: 'https://npm.pkg.github.com'
122+
node-version-file: ".tool-versions"
123+
registry-url: "https://npm.pkg.github.com"
142124

143125
- name: Install dependencies
144126
env:

.github/workflows/release_created.yaml

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,25 @@ name: Github Release Created
22

33
on:
44
release:
5-
types: ["released"] # Inherits all input defaults
6-
workflow_dispatch:
7-
inputs:
8-
releaseVersion:
9-
description: Release, tag, branch, or commit ID to be used for deployment
10-
required: false
11-
default: "main"
12-
type: string
5+
types: [ "released" ]
136

147
concurrency:
158
group: ${{ github.workflow }}-${{ github.ref }}
169
cancel-in-progress: false
1710

18-
jobs:
19-
deploy-main:
20-
name: Deploy changes to main in nonprod AWS Account
21-
runs-on: ubuntu-latest
22-
23-
permissions:
24-
id-token: write
25-
contents: read
26-
27-
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
30-
- name: Deploy Nonprod Environment
31-
env:
32-
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
33-
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
34-
run: |
35-
bash .github/scripts/dispatch_internal_repo_workflow.sh \
36-
--releaseVersion "${{ github.event.release.tag_name || inputs.releaseVersion }}" \
37-
--targetWorkflow "dispatch-deploy-static-notify-supplier-api-env.yaml" \
38-
--targetEnvironment "main" \
39-
--targetAccountGroup "nhs-notify-supplier-api-nonprod" \
40-
--targetComponent "api" \
41-
--terraformAction "apply"
42-
deploy-proxy:
43-
needs: deploy-main #wait for backend deploy to complete
44-
name: "Deploy proxy"
45-
runs-on: ubuntu-latest
46-
timeout-minutes: 10
11+
permissions:
12+
id-token: write
13+
contents: read
14+
packages: read
4715

48-
permissions:
49-
id-token: write
50-
contents: read
51-
actions: read
52-
53-
env:
54-
PROXYGEN_API_NAME: nhs-notify-supplier
55-
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
56-
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
57-
58-
steps:
59-
- name: "Checkout code"
60-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
61-
- name: "Build proxies"
62-
uses: ./.github/actions/build-proxies
63-
with:
64-
environment: "main"
65-
apimEnv: "int"
66-
runId: "${{ github.run_id }}"
67-
releaseVersion: "${{ github.event.release.tag_name || inputs.releaseVersion }}"
68-
isRelease: true
16+
jobs:
17+
deploy:
18+
uses: ./.github/workflows/deploy-supplier-api.yaml
19+
secrets: inherit
20+
with:
21+
source_type: release
22+
source_value: ${{ github.event.release.tag_name }}
23+
deploy_backend: true
24+
backend_account_group: nonprod
25+
deploy_proxy: true
26+
apim_environment: int

0 commit comments

Comments
 (0)