Skip to content

Commit 84a745f

Browse files
authored
Merge branch 'main' into feature/CCM-11207_doc
2 parents 795a165 + c552ef2 commit 84a745f

File tree

125 files changed

+2153
-923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2153
-923
lines changed

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

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ description: "Build Proxies"
44
inputs:
55
version:
66
description: "Version number"
7+
required: false
8+
releaseVersion:
9+
description: "Release, tag, branch, or commit ID to be used for deployment"
710
required: true
11+
environment:
12+
description: "Deployment environment"
13+
required: true
14+
apimEnv:
15+
description: "APIM environment"
16+
required: true
17+
runId:
18+
description: "GitHub Actions run ID to fetch the OAS artifact from"
19+
required: true
20+
buildSandbox:
21+
description: "Whether to build the sandbox OAS spec"
22+
required: false
23+
default: false
24+
targetComponent:
25+
description: "Name of the Component to deploy"
26+
required: true
27+
default: 'api'
828

929
runs:
1030
using: composite
@@ -25,46 +45,71 @@ runs:
2545
shell: bash
2646
run: |
2747
48+
ENV="${{ inputs.apimEnv }}"
49+
if [[ "$ENV" == "internal-dev" || "$ENV" == *pr ]]; then
50+
echo "TARGET_DOMAIN=suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
51+
elif [[ "$ENV" == "int" ]]; then
52+
echo "TARGET_DOMAIN=suppliers.nonprod.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
53+
elif [[ "$ENV" == "prod" ]]; then
54+
echo "TARGET_DOMAIN=suppliers.prod.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
55+
else
56+
echo "TARGET_DOMAIN=suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
57+
fi
58+
2859
if [ -z $PR_NUMBER ]
2960
then
3061
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
31-
echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
62+
echo "TARGET=https://main.$TARGET_DOMAIN" >> $GITHUB_ENV
3263
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
3364
echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
3465
else
35-
echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
66+
echo "TARGET=https://pr$PR_NUMBER.$TARGET_DOMAIN" >> $GITHUB_ENV
3667
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3768
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3869
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
3970
fi
4071
41-
- name: Install Proxygen client
42-
shell: bash
43-
run: |
44-
# Install proxygen cli
45-
pip install pipx
46-
pipx install proxygen-cli
47-
48-
# Setup proxygen auth and settings
49-
mkdir -p ${HOME}/.proxygen
50-
echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
51-
envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
52-
envsubst < ./.github/proxygen-credentials-template.yaml | cat
53-
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
54-
envsubst < ./.github/proxygen-settings.yaml | cat
55-
56-
- name: Build sandbox oas
72+
- name: Build ${{ inputs.apimEnv }} oas
5773
working-directory: .
74+
env:
75+
APIM_ENV: ${{ inputs.apimEnv }}
5876
shell: bash
5977
run: |
60-
make build-json-oas-spec APIM_ENV=sandbox
78+
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
79+
then
80+
echo "Building sandbox OAS spec"
81+
make build-json-oas-spec APIM_ENV=sandbox
82+
else
83+
echo "Building env specific OAS spec"
84+
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
85+
fi
6186
62-
- name: Set docker tag
63-
shell: bash
64-
run: |
65-
jq --arg newtag "$SANDBOX_TAG" '.["x-nhsd-apim"].target.containers[0].image.tag = $newtag' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
87+
if [[ $APIM_ENV == *-pr ]]; then
88+
echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
89+
APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')
90+
fi
91+
echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
92+
93+
- name: Upload OAS Spec
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: ${{ env.APIM_ENV }}-build-output
97+
path: ./build
6698

67-
- name: Deploy to Internal Dev Sandbox
99+
- name: Trigger deploy proxy
100+
env:
101+
PR_TRIGGER_PAT: ${{ env.PR_TRIGGER_PAT }}
68102
shell: bash
69103
run: |
70-
proxygen instance deploy internal-dev-sandbox $INSTANCE build/notify-supplier.json --no-confirm
104+
.github/scripts/dispatch_internal_repo_workflow.sh \
105+
--infraRepoName "nhs-notify-supplier-api" \
106+
--releaseVersion "${{ inputs.releaseVersion }}" \
107+
--targetComponent "${{ inputs.targetComponent }}" \
108+
--targetWorkflow "proxy-deploy.yaml" \
109+
--targetEnvironment "${{ inputs.environment }}" \
110+
--runId "${{ inputs.runId }}" \
111+
--buildSandbox ${{ inputs.buildSandbox }} \
112+
--apimEnvironment "${{ env.APIM_ENV }}" \
113+
--boundedContext "notify-supplier" \
114+
--targetDomain "$TARGET_DOMAIN" \
115+
--version "${{ inputs.version }}"

.github/copilot-instructions.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copilot Instructions for NHS Notify Supplier API
2+
3+
## Project Overview
4+
5+
- This repository provides the NHS Notify Supplier API for print suppliers to integrate with NHS Notify message queueing.
6+
- Major components: OpenAPI specification (`specification/api/notify-supplier.yml`), SDKs (`sdk/`), server implementations (`server/`, `src/server/host`), and Lambda handlers (`lambdas/`).
7+
- Data flows: API requests are modeled via OAS, processed by server/Lambda code, and may interact with AWS services (e.g., S3, database).
8+
9+
## Developer Workflows
10+
11+
- **Build SDKs and Docs:**
12+
- Run `make clean && make build` to generate Python/TypeScript SDKs and HTML docs from the OAS spec.
13+
- Serve docs locally with `make serve` [default](http://localhost:3050).
14+
- **CI/CD:**
15+
- PRs trigger CI via GitHub Actions (`.github/workflows/cicd-1-pull-request.yaml`).
16+
- Merging to `main` creates a pre-release; deployments use `.github/workflows/cicd-3-deploy.yaml`.
17+
- **Dev Environment:**
18+
- Use the provided devcontainer for setup and configuration. Avoid manual SDK changes; always rebuild.
19+
20+
## Project-Specific Conventions
21+
22+
- **SDKs:**
23+
- Never manually edit files in `sdk/`; always regenerate from the OAS spec.
24+
- SDK folder is excluded from git and built/released via CI.
25+
- **Servers:**
26+
- Server code is generated at build time from OAS specs. See `server/` and `src/server/host` for custom logic.
27+
- **Test Data:**
28+
- Use `scripts/test-data` to generate and upload test letters to S3. Example command:
29+
30+
```bash
31+
npm run cli -- create-letter --supplier-id ... --environment ... --awsAccountId ... --letter-id ... --group-id ... --specification-id ... --status PENDING
32+
```
33+
34+
## Integration Points
35+
36+
- **External Services:**
37+
- AWS S3 and database for test data and letter storage.
38+
- OpenAPI Generator CLI for SDK/server generation.
39+
- **Documentation:**
40+
- Latest [docs](https://nhsdigital.github.io/nhs-notify-supplier-api/)
41+
- Local docs: `make serve`
42+
43+
## Key Files & Directories
44+
45+
- `specification/api/notify-supplier.yml`: Main API spec
46+
- `sdk/`: Generated SDKs (Python, TypeScript, CSharp)
47+
- `server/`, `src/server/host`: Server implementations
48+
- `lambdas/`: Lambda handlers
49+
- `scripts/test-data/`: Test data generation scripts
50+
- `docs/`: Documentation source
51+
52+
## Patterns & Examples
53+
54+
- Always regenerate SDKs/servers after spec changes.
55+
- Use Makefile targets for all build/test workflows.
56+
- Reference the README for up-to-date workflow and integration details.
57+
58+
---
59+
For unclear or missing conventions, consult `/README.md` or ask maintainers for guidance.

.github/scripts/dispatch_internal_repo_workflow.sh

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ while [[ $# -gt 0 ]]; do
6868
internalRef="$2"
6969
shift 2
7070
;;
71+
--runId) # Github Run ID (optional)
72+
runId="$2"
73+
shift 2
74+
;;
7175
--overrides) # Terraform overrides for passing in extra variables (optional)
7276
overrides="$2"
7377
shift 2
@@ -80,6 +84,26 @@ while [[ $# -gt 0 ]]; do
8084
overrideRoleName="$2"
8185
shift 2
8286
;;
87+
--buildSandbox) # Build sandbox flag (optional)
88+
buildSandbox="$2"
89+
shift 2
90+
;;
91+
--apimEnvironment) # APIM environment (optional)
92+
apimEnvironment="$2"
93+
shift 2
94+
;;
95+
--boundedContext) # Bounded context (optional)
96+
boundedContext="$2"
97+
shift 2
98+
;;
99+
--targetDomain) # Target domain (optional)
100+
targetDomain="$2"
101+
shift 2
102+
;;
103+
--version) # Version (optional)
104+
version="$2"
105+
shift 2
106+
;;
83107
*)
84108
echo "[ERROR] Unknown argument: $1"
85109
exit 1
@@ -101,6 +125,30 @@ if [[ -z "$internalRef" ]]; then
101125
internalRef="main"
102126
fi
103127

128+
if [[ -z "$runId" ]]; then
129+
runId=""
130+
fi
131+
132+
if [[ -z "$buildSandbox" ]]; then
133+
buildSandbox=""
134+
fi
135+
136+
if [[ -z "$apimEnvironment" ]]; then
137+
apimEnvironment=""
138+
fi
139+
140+
if [[ -z "$boundedContext" ]]; then
141+
boundedContext=""
142+
fi
143+
144+
if [[ -z "$targetDomain" ]]; then
145+
targetDomain=""
146+
fi
147+
148+
if [[ -z "$version" ]]; then
149+
version=""
150+
fi
151+
104152
echo "==================== Workflow Dispatch Parameters ===================="
105153
echo " infraRepoName: $infraRepoName"
106154
echo " releaseVersion: $releaseVersion"
@@ -114,6 +162,12 @@ echo " overrides: $overrides"
114162
echo " overrideProjectName: $overrideProjectName"
115163
echo " overrideRoleName: $overrideRoleName"
116164
echo " targetProject: $targetProject"
165+
echo " runId: $runId"
166+
echo " buildSandbox: $buildSandbox"
167+
echo " apimEnvironment: $apimEnvironment"
168+
echo " boundedContext: $boundedContext"
169+
echo " targetDomain: $targetDomain"
170+
echo " version: $version"
117171

118172
DISPATCH_EVENT=$(jq -ncM \
119173
--arg infraRepoName "$infraRepoName" \
@@ -127,6 +181,12 @@ DISPATCH_EVENT=$(jq -ncM \
127181
--arg overrideProjectName "$overrideProjectName" \
128182
--arg overrideRoleName "$overrideRoleName" \
129183
--arg targetProject "$targetProject" \
184+
--arg runId "$runId" \
185+
--arg buildSandbox "$buildSandbox" \
186+
--arg apimEnvironment "$apimEnvironment" \
187+
--arg boundedContext "$boundedContext" \
188+
--arg targetDomain "$targetDomain" \
189+
--arg version "$version" \
130190
'{
131191
"ref": "'"$internalRef"'",
132192
"inputs": (
@@ -135,18 +195,26 @@ DISPATCH_EVENT=$(jq -ncM \
135195
(if $overrideProjectName != "" then { "overrideProjectName": $overrideProjectName } else {} end) +
136196
(if $overrideRoleName != "" then { "overrideRoleName": $overrideRoleName } else {} end) +
137197
(if $targetProject != "" then { "targetProject": $targetProject } else {} end) +
198+
(if $overrides != "" then { "overrides": $overrides } else {} end) +
199+
(if $runId != "" then { "runId": $runId } else {} end) +
200+
(if $buildSandbox != "" then { "buildSandbox": $buildSandbox } else {} end) +
201+
(if $apimEnvironment != "" then { "apimEnvironment": $apimEnvironment } else {} end) +
202+
(if $boundedContext != "" then { "boundedContext": $boundedContext } else {} end) +
203+
(if $targetDomain != "" then { "targetDomain": $targetDomain } else {} end) +
204+
(if $version != "" then { "version": $version } else {} end) +
205+
(if $targetAccountGroup != "" then { "targetAccountGroup": $targetAccountGroup } else {} end) +
138206
{
139207
"releaseVersion": $releaseVersion,
140208
"targetEnvironment": $targetEnvironment,
141-
"targetAccountGroup": $targetAccountGroup,
142209
"targetComponent": $targetComponent,
143-
"overrides": $overrides,
144210
}
145211
)
146212
}')
147213

148214
echo "[INFO] Triggering workflow '$targetWorkflow' in nhs-notify-internal..."
149215

216+
echo "[DEBUG] Dispatch event payload: $DISPATCH_EVENT"
217+
150218
trigger_response=$(curl -s -L \
151219
--fail \
152220
-X POST \
@@ -185,16 +253,12 @@ for _ in {1..18}; do
185253
workflow_run_url=$(echo "$response" | jq -r \
186254
--arg targetWorkflow "$targetWorkflow" \
187255
--arg targetEnvironment "$targetEnvironment" \
188-
--arg targetAccountGroup "$targetAccountGroup" \
189256
--arg targetComponent "$targetComponent" \
190-
--arg terraformAction "$terraformAction" \
191257
'.workflow_runs[]
192258
| select(.path == ".github/workflows/" + $targetWorkflow)
193259
| select(.name
194260
| contains($targetEnvironment)
195-
and contains($targetAccountGroup)
196261
and contains($targetComponent)
197-
and contains($terraformAction)
198262
)
199263
| .url')
200264

0 commit comments

Comments
 (0)