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
13 changes: 11 additions & 2 deletions .github/workflows/schedule-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ env:
on:
workflow_dispatch:
inputs:
action:
description: 'Deployment action'
required: true
default: 'add'
type: choice
options:
- 'add'
- 'remove'
deployments:
description: 'List of matchkeys with short commit hash SHA e.g. goldrush2024:1163910,isxn:d88522c'
description: 'List of matchkeys with commit hash SHA e.g. goldrush2024:1163910,isxn:d88522c'
required: true
type: string

Expand Down Expand Up @@ -76,10 +84,11 @@ jobs:

- name: Show schedule summary
run: |
echo "schedule: ${{ steps.verify-inputs.outputs.schedule }}" >> "$GITHUB_STEP_SUMMARY"
echo "schedule: ${{ inputs.action }}: ${{ steps.verify-inputs.outputs.schedule }}" >> "$GITHUB_STEP_SUMMARY"

- name: Append JSONL to file
env:
ACTION: ${{ inputs.action }}
SCHEDULE: ${{ steps.verify-inputs.outputs.schedule }}
JOB_ID: ${{ github.run_number }}
run: python3 .github/workflows/scripts/schedule_matchkeys.py -l info
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/scripts/schedule_matchkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pathlib import Path
import sys

SCRIPT_VERSION = "1.0.2"
SCRIPT_VERSION = "1.1.0"

LOGLEVELS = {
"debug": logging.DEBUG,
Expand Down Expand Up @@ -49,6 +49,11 @@ def get_options():
loglevel = LOGLEVELS.get(args.loglevel.lower(), logging.NOTSET)
LOGGER.setLevel(loglevel)
LOGGER.info("Using script version: %s", SCRIPT_VERSION)
try:
action = os.environ["ACTION"]
except KeyError:
LOGGER.error("Missing env: ACTION")
options_okay = False
try:
schedule = os.environ["SCHEDULE"]
except KeyError:
Expand All @@ -62,10 +67,10 @@ def get_options():
schedule_pn = PROG_PATH.parent.parent.parent.joinpath("js/schedule-matchkeys.jsonl")
if not options_okay:
sys.exit(2)
return int(job_id), schedule, schedule_pn
return int(job_id), action, schedule, schedule_pn


def append_schedule(job_id, schedule, schedule_pn):
def append_schedule(job_id, action, schedule, schedule_pn):
"""
Composes the JSONL and appends to file.
"""
Expand All @@ -74,6 +79,7 @@ def append_schedule(job_id, schedule, schedule_pn):
json_packet["scheduleDate"] = (
datetime.now(timezone.utc).replace(microsecond=0).isoformat()
)
json_packet["action"] = action
json_packet["deployment"] = schedule
with open(schedule_pn, mode="a", encoding="utf-8") as output_fh:
output_fh.write(json.dumps(json_packet, sort_keys=False, indent=None))
Expand All @@ -84,9 +90,9 @@ def main():
"""
Append the schedule JSONL to schedule-matchkeys.jsonl file.
"""
job_id, schedule, schedule_pn = get_options()
job_id, action, schedule, schedule_pn = get_options()
LOGGER.debug("schedule=%s schedule_pn=%s", schedule, schedule_pn)
append_schedule(job_id, schedule, schedule_pn)
append_schedule(job_id, action, schedule, schedule_pn)


if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,6 @@ For each matchkey that is to form the pool, specify its matchkey name and the re

For example `goldrush2024:1163910,isxn:d88522c`

Specify the `action` "add or remove".

Raise a pull-request to target mainline.
2 changes: 1 addition & 1 deletion js/schedule-matchkeys.jsonl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id": 19, "scheduleDate": "2026-08-10T08:03:57+00:00", "deployment": "goldrush2024:1163910,isxn:d88522c"}
{"id": 21, "scheduleDate": "2026-08-12T04:38:39+00:00", "action": "add", "deployment": "goldrush2024:1163910,isxn:d88522c"}