Skip to content

Commit 5bd2b8e

Browse files
committed
Merge remote-tracking branch 'origin/bugfix/CCM-19310-lte-constraints' into bugfix/CCM-19310-lte-constraints
2 parents eaea017 + c8287a8 commit 5bd2b8e

49 files changed

Lines changed: 9339 additions & 8755 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "Bundle eventbridge-publish"
2+
description: "Build and package the eventbridge-publish release bundle (eventbridge-publish-bundle.tgz) from the workspace sources."
3+
4+
inputs:
5+
node-version:
6+
description: "Node.js version to use"
7+
required: true
8+
run-typecheck:
9+
description: "Run workspace typecheck before bundling"
10+
required: false
11+
default: "true"
12+
13+
outputs:
14+
tarball-path:
15+
description: "Path to the generated tarball"
16+
value: ${{ steps.bundle.outputs.tarball_path }}
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Set up Node.js
22+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
23+
with:
24+
node-version: "${{ inputs.node-version }}"
25+
cache: npm
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: |
30+
set -euo pipefail
31+
npm ci
32+
33+
- name: Generate dependencies
34+
shell: bash
35+
run: |
36+
set -euo pipefail
37+
npm run generate-dependencies --workspaces --if-present
38+
39+
- name: Typecheck
40+
if: inputs.run-typecheck == 'true'
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
npm run typecheck --workspaces --if-present
45+
46+
- name: Build eventbridge-publish bundle
47+
shell: bash
48+
run: |
49+
set -euo pipefail
50+
npm run bundle:release --workspace @supplier-config/eventbridge-publisher
51+
52+
- name: Smoke-test bundle
53+
shell: bash
54+
run: |
55+
set -euo pipefail
56+
node packages/eventbridge-publisher/artifacts/eventbridge-publish/index.cjs --help > /dev/null
57+
58+
- name: Package tarball
59+
id: bundle
60+
shell: bash
61+
run: |
62+
set -euo pipefail
63+
tarball="eventbridge-publish-bundle.tgz"
64+
tar -czf "$tarball" -C packages/eventbridge-publisher/artifacts/eventbridge-publish .
65+
echo "tarball_path=$tarball" >> "$GITHUB_OUTPUT"

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
name: "Set CI/CD metadata"
1717
runs-on: ubuntu-latest
1818
timeout-minutes: 1
19+
permissions:
20+
contents: read # for actions/checkout
21+
pull-requests: read # for gh pr list
1922
outputs:
2023
build_datetime_london: ${{ steps.variables.outputs.build_datetime_london }}
2124
build_datetime: ${{ steps.variables.outputs.build_datetime }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release eventbridge-publish bundle
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
bundle-and-upload:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
18+
- name: Read Node version
19+
id: versions
20+
shell: bash
21+
run: |
22+
set -euo pipefail
23+
echo "node=$(grep '^nodejs\s' .tool-versions | awk '{print $2}')" >> "$GITHUB_OUTPUT"
24+
25+
- name: Bundle eventbridge-publish
26+
id: bundle
27+
uses: ./.github/actions/bundle-eventbridge-publish
28+
with:
29+
node-version: "${{ steps.versions.outputs.node }}"
30+
run-typecheck: "true"
31+
32+
- name: Upload release asset
33+
if: github.event_name == 'release'
34+
env:
35+
GH_TOKEN: ${{ github.token }}
36+
shell: bash
37+
run: |
38+
set -euo pipefail
39+
gh release upload "${{ github.event.release.tag_name }}" "${{ steps.bundle.outputs.tarball-path }}" --clobber
40+
41+
- name: Upload bundle as workflow artifact
42+
if: github.event_name != 'release'
43+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
44+
with:
45+
name: eventbridge-publish-bundle
46+
path: "${{ steps.bundle.outputs.tarball-path }}"

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ jobs:
4545
with:
4646
version: "${{ inputs.version }}"
4747

48-
ddb-publish-bundle:
49-
name: "Bundle ddb-publish CLI"
48+
eventbridge-publish-bundle:
49+
name: "Bundle eventbridge-publish CLI"
5050
runs-on: ubuntu-latest
5151
timeout-minutes: 3
5252
steps:
5353
- name: "Checkout code"
5454
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5555

56-
- name: "Bundle ddb-publish"
56+
- name: "Bundle eventbridge-publish"
5757
id: bundle
58-
uses: ./.github/actions/bundle-ddb-publish
58+
uses: ./.github/actions/bundle-eventbridge-publish
5959
with:
6060
node-version: "${{ inputs.nodejs_version }}"
6161
run-typecheck: "false"
6262

6363
- name: "Upload bundle as workflow artifact"
6464
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v5
6565
with:
66-
name: ddb-publish-bundle
66+
name: eventbridge-publish-bundle
6767
path: "${{ steps.bundle.outputs.tarball-path }}"
6868

6969
artefact-1:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ clean:: # Clean-up project resources (main) @Operations
2323
rm -f .version
2424
# TODO: Implement project resources clean-up step
2525

26-
config:: _install-dependencies version # Configure development environment (main) @Configuration
26+
config:: _install-dependencies # Configure development environment (main) @Configuration
2727
(cd docs && make install)
2828

2929
internal-config:
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: "Publish supplier config to EventBridge"
2+
description: "Reads config from a file store and publishes records to an event bus."
3+
author: "NHS Notify"
4+
5+
inputs:
6+
source-path:
7+
description: "Path to the config store root directory"
8+
required: true
9+
event-bus-arn:
10+
description: "ARN of event bus to publish to. Not required if dry-run is specified"
11+
required: false
12+
dry-run:
13+
description: "Validate only (no AWS calls). Does not require credentials."
14+
required: false
15+
default: "false"
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Resolve and download eventbridge-publish bundle
21+
shell: bash
22+
env:
23+
GH_TOKEN: ${{ github.token }}
24+
CALLER_REPO: ${{ github.repository }}
25+
ACTION_REPO: ${{ github.action_repository }}
26+
ACTION_REF: ${{ github.action_ref }}
27+
RELEASE_ASSET_NAME: eventbridge-publish-bundle.tgz
28+
WORKFLOW_ARTIFACT_NAME: eventbridge-publish-bundle
29+
run: |
30+
set -euo pipefail
31+
32+
download_dir="${RUNNER_TEMP}/eventbridge-publish"
33+
unpack_dir="${download_dir}/unpacked"
34+
35+
mkdir -p "${download_dir}" "${unpack_dir}"
36+
37+
echo "[eventbridge-publish] caller_repo=${CALLER_REPO}"
38+
echo "[eventbridge-publish] action_repo=${ACTION_REPO}"
39+
echo "[eventbridge-publish] action_ref=${ACTION_REF:-<empty>}"
40+
41+
if [[ -z "${ACTION_REF}" ]]; then
42+
echo "ERROR: github.action_ref is empty; unable to locate release asset or branch artifact." >&2
43+
exit 1
44+
fi
45+
46+
if [[ -z "${ACTION_REPO}" ]]; then
47+
echo "ERROR: github.action_repository is empty; unable to determine where to fetch bundle artifacts." >&2
48+
exit 1
49+
fi
50+
51+
# Prefer release assets when the action ref is a tag with a matching release in the action repo.
52+
if gh release view "${ACTION_REF}" --repo "${ACTION_REPO}" >/dev/null 2>&1; then
53+
echo "[eventbridge-publish] Found release for ref '${ACTION_REF}' in '${ACTION_REPO}'. Downloading '${RELEASE_ASSET_NAME}'."
54+
gh release download "${ACTION_REF}" --repo "${ACTION_REPO}" --pattern "${RELEASE_ASSET_NAME}" --dir "${download_dir}"
55+
tar -xzf "${download_dir}/${RELEASE_ASSET_NAME}" -C "${unpack_dir}"
56+
echo "[eventbridge-publish] Bundle extracted from release asset."
57+
exit 0
58+
fi
59+
60+
# Otherwise treat the ref as a branch-like ref and fetch the latest successful CI artifact from the action repo.
61+
branch="${ACTION_REF#refs/heads/}"
62+
echo "[eventbridge-publish] No release found for ref '${ACTION_REF}'. Falling back to latest workflow artifact on branch '${branch}' from '${ACTION_REPO}'."
63+
64+
run_id=""
65+
workflow_used=""
66+
67+
for workflow_file in "stage-3-build.yaml" "cicd-1-pull-request.yaml"; do
68+
echo "[eventbridge-publish] Looking for successful runs in workflow '${workflow_file}'."
69+
70+
set +e
71+
run_id_candidate="$(gh run list \
72+
--repo "${ACTION_REPO}" \
73+
--workflow "${workflow_file}" \
74+
--branch "${branch}" \
75+
--status success \
76+
--json databaseId \
77+
--jq '.[0].databaseId' 2>/tmp/eventbridge_publish_run_list_err.log)"
78+
rc=$?
79+
set -e
80+
81+
if [[ $rc -ne 0 ]]; then
82+
if grep -q "HTTP 404" /tmp/eventbridge_publish_run_list_err.log; then
83+
echo "[eventbridge-publish] Workflow '${workflow_file}' not found on default branch; trying next workflow candidate."
84+
continue
85+
fi
86+
87+
echo "ERROR: Failed to query workflow runs from '${ACTION_REPO}' for workflow '${workflow_file}'." >&2
88+
cat /tmp/eventbridge_publish_run_list_err.log >&2 || true
89+
echo "HINT: ensure the token has read access to '${ACTION_REPO}' and workflow permissions allow actions read." >&2
90+
exit 1
91+
fi
92+
93+
if [[ -n "${run_id_candidate}" && "${run_id_candidate}" != "null" ]]; then
94+
run_id="${run_id_candidate}"
95+
workflow_used="${workflow_file}"
96+
break
97+
fi
98+
done
99+
100+
if [[ -z "${run_id}" || "${run_id}" == "null" ]]; then
101+
echo "ERROR: Could not find a successful run on branch '${branch}' in '${ACTION_REPO}' containing artifact '${WORKFLOW_ARTIFACT_NAME}'. Checked workflows: stage-3-build.yaml, cicd-1-pull-request.yaml." >&2
102+
exit 1
103+
fi
104+
105+
echo "[eventbridge-publish] Downloading artifact '${WORKFLOW_ARTIFACT_NAME}' from workflow run ${run_id} (${workflow_used}) in '${ACTION_REPO}'."
106+
gh run download "${run_id}" --repo "${ACTION_REPO}" --name "${WORKFLOW_ARTIFACT_NAME}" --dir "${download_dir}"
107+
108+
tarball_path="${download_dir}/${RELEASE_ASSET_NAME}"
109+
if [[ ! -f "${tarball_path}" ]]; then
110+
echo "ERROR: Downloaded artifact did not contain expected tarball '${RELEASE_ASSET_NAME}'." >&2
111+
ls -la "${download_dir}" >&2
112+
exit 1
113+
fi
114+
115+
tar -xzf "${tarball_path}" -C "${unpack_dir}"
116+
echo "[eventbridge-publish] Bundle extracted from workflow artifact."
117+
118+
- name: Run publisher
119+
shell: bash
120+
run: |
121+
set -euo pipefail
122+
123+
echo "[eventbridge-publish] Starting publish run"
124+
echo "[eventbridge-publish] source='${{ inputs.source-path }}' event-bus-arn='${{ inputs.event-bus-arn }}' dry-run='${{ inputs.dry-run }}'"
125+
126+
node "${RUNNER_TEMP}/eventbridge-publish/unpacked/index.cjs" \
127+
--source "${{ inputs.source-path }}" \
128+
$([[ -n "${{ inputs.event-bus-arn }}" ]] && echo "--event-bus-arn ${{ inputs.event-bus-arn }}") \
129+
$([[ "${{ inputs.dry-run }}" == "true" ]] && echo "--dry-run")
130+
131+
echo "[eventbridge-publish] Publish run completed"

docs/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ GEM
2929
ffi (1.16.3)
3030
forwardable-extended (2.6.0)
3131
gemoji (4.1.0)
32-
google-protobuf (4.29.2-x86_64-linux)
32+
google-protobuf (4.33.6-x86_64-linux-gnu)
3333
bigdecimal
3434
rake (>= 13)
3535
html-pipeline (2.14.3)

docs/package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)