From 98d35a13200b88e645f47fb32cf316d02a03067c Mon Sep 17 00:00:00 2001 From: David Crossley Date: Sun, 23 Aug 2026 21:03:09 +1000 Subject: [PATCH 1/3] Add branch property schedule-deployments.jsonl DEVOPS-8235 --- .github/workflows/schedule-deployment.yml | 1 + .../workflows/scripts/schedule_deployments.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/schedule-deployment.yml b/.github/workflows/schedule-deployment.yml index b4b8a01..fcc8d62 100644 --- a/.github/workflows/schedule-deployment.yml +++ b/.github/workflows/schedule-deployment.yml @@ -101,6 +101,7 @@ jobs: env: ACTION: ${{ inputs.action }} SCHEDULE: ${{ steps.verify-inputs.outputs.schedule }} + BRANCH_NAME: ${GITHUB_REF##*/} DIR_OUTPUT: ${{ secrets.REPO_NAME_GITOPS }} JOB_ID: ${{ github.run_number }} run: uv run .github/workflows/scripts/schedule_deployments.py -l info diff --git a/.github/workflows/scripts/schedule_deployments.py b/.github/workflows/scripts/schedule_deployments.py index b8544eb..16560a3 100755 --- a/.github/workflows/scripts/schedule_deployments.py +++ b/.github/workflows/scripts/schedule_deployments.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """ +Generate and commit Kubernetes custom resource for a pool at the GitOps repository. Append the schedule JSONL to schedule-deployments.jsonl file. NOTE: Please use 'black' to re-format code. @@ -26,7 +27,7 @@ from jinja2 import Environment, FileSystemLoader -SCRIPT_VERSION = "1.5.3" +SCRIPT_VERSION = "1.5.4" LOGLEVELS = { "debug": logging.DEBUG, @@ -71,6 +72,11 @@ def get_options(): except KeyError: LOGGER.error("Missing env: SCHEDULE") options_okay = False + try: + branch = os.environ["BRANCH_NAME"] + except KeyError: + LOGGER.error("Missing env: BRANCH_NAME") + options_okay = False try: dir_output = os.environ["DIR_OUTPUT"] except KeyError: @@ -92,7 +98,7 @@ def get_options(): options_okay = False if not options_okay: sys.exit(2) - return int(job_id), action, schedule, templates_pn, dir_storage + return int(job_id), branch, action, schedule, templates_pn, dir_storage def load_matchers_summary(): @@ -206,7 +212,7 @@ def generate_cr(templates_pn, pool_details, dir_storage): output_fh.write("\n") -def append_schedule(job_id, action, id_pool, dir_storage): +def append_schedule(job_id, branch, action, id_pool, dir_storage): """ Composes the JSONL and appends to file. """ @@ -221,6 +227,7 @@ def append_schedule(job_id, action, id_pool, dir_storage): json_packet["action"] = action json_packet["initialized"] = False json_packet["poolId"] = id_pool + json_packet["branch"] = branch with open(schedule_pn, mode="a", encoding="utf-8") as output_fh: output_fh.write(json.dumps(json_packet, sort_keys=False, indent=None)) output_fh.write("\n") @@ -228,13 +235,14 @@ def append_schedule(job_id, action, id_pool, dir_storage): def main(): """ + Generate and commit Kubernetes custom resource for a pool at the GitOps repository. Append the schedule JSONL to schedule-deployments.jsonl file. """ - job_id, action, schedule, templates_pn, dir_storage = get_options() + job_id, branch, action, schedule, templates_pn, dir_storage = get_options() matchers_summary = load_matchers_summary() id_pool, pool_details = assemble_pool_details(schedule, matchers_summary) generate_cr(templates_pn, pool_details, dir_storage) - append_schedule(job_id, action, id_pool, dir_storage) + append_schedule(job_id, branch, action, id_pool, dir_storage) if __name__ == "__main__": From 559ff5c5164c240784b9ba8e39fb0c26c389bcd0 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Sun, 23 Aug 2026 21:35:59 +1000 Subject: [PATCH 2/3] Improve README schedule-deployment DEVOPS-8235 --- js/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/README.md b/js/README.md index 8475a6e..fc17382 100644 --- a/js/README.md +++ b/js/README.md @@ -117,7 +117,7 @@ Each matcher is briefly explained in the [js/matchers/README.md](matchers/README For each matcher there is an entry in the [js/package.json](package.json) file to declare its test to be run using Node.js (e.g. `test-goldrush2024`). To add a new matcher, follow the structure of an existing matcher. -Also declare it at the file [matchers-summary.json](../matchers-summary.json). +Also declare it at the [matchers-summary.json](../matchers-summary.json) file. > [!IMPORTANT] > The matcher names are restricted to alpha-numeric or hyphen (dash) characters. @@ -197,11 +197,11 @@ Note that there is currently a tiny glitch with this workflow. The first git pus ### Workflow schedule-deployment -The [schedule-deployment](https://github.com/indexdata/reservoir-scripts/actions/workflows/schedule-deployment.yml) Workflow adds an entry to the [schedule-deployments.jsonl](schedule-deployments.jsonl) file. +The [schedule-deployment](https://github.com/indexdata/reservoir-scripts/actions/workflows/schedule-deployment.yml) Workflow generates and commits a Kubernetes custom resource for the declared pool. Other back-room processes will conduct the deployment of the matchers and the pool. -When matchers are ready, then select the Workflow and trigger a run via the workflow_dispatch event (i.e. select `Run workflow` on the right-hand side). +When matchers are ready, then select the Workflow and trigger a run via the `workflow_dispatch` event (i.e. select `Run workflow` on the right-hand side). Specify the branch (note that `main` branch is not allowed). @@ -211,5 +211,5 @@ For example `goldrush2024,isxn` Specify the `action` "add or remove". -The Workflow will determine the short git commit SHA for the head of the branch. +The Workflow will determine the git commit SHA for the head of the branch. From 6559d236ba0366954ed51a6b59b113284c605a1c Mon Sep 17 00:00:00 2001 From: David Crossley Date: Sun, 23 Aug 2026 21:51:27 +1000 Subject: [PATCH 3/3] Use ref_name for branch DEVOPS-8235 --- .github/workflows/schedule-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/schedule-deployment.yml b/.github/workflows/schedule-deployment.yml index fcc8d62..d381e82 100644 --- a/.github/workflows/schedule-deployment.yml +++ b/.github/workflows/schedule-deployment.yml @@ -101,7 +101,7 @@ jobs: env: ACTION: ${{ inputs.action }} SCHEDULE: ${{ steps.verify-inputs.outputs.schedule }} - BRANCH_NAME: ${GITHUB_REF##*/} + BRANCH_NAME: ${{ github.ref_name }} DIR_OUTPUT: ${{ secrets.REPO_NAME_GITOPS }} JOB_ID: ${{ github.run_number }} run: uv run .github/workflows/scripts/schedule_deployments.py -l info