Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/schedule-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
env:
ACTION: ${{ inputs.action }}
SCHEDULE: ${{ steps.verify-inputs.outputs.schedule }}
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
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/scripts/schedule_deployments.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -26,7 +27,7 @@

from jinja2 import Environment, FileSystemLoader

SCRIPT_VERSION = "1.5.3"
SCRIPT_VERSION = "1.5.4"

LOGLEVELS = {
"debug": logging.DEBUG,
Expand Down Expand Up @@ -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:
Expand All @@ -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():
Expand Down Expand Up @@ -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.
"""
Expand All @@ -221,20 +227,22 @@ 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")


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__":
Expand Down
8 changes: 4 additions & 4 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).

Expand All @@ -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.

Loading