Add cron workflow to update driverless printer list - #234
Open
hissamshar wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Finding(s):
- The validation step can fail with an unhelpful Python traceback if
driverless.jsonis valid JSON but not an array of objects; adding explicit shape checks would make failures consistently produce the intended::error::…annotations.
This PR adds a GitHub Actions workflow to automatically refresh the site’s driverless printer dataset on a monthly schedule (and on manual dispatch), creating a PR for changes to the generated JSON. This fits the repo’s static-site workflow by keeping public/assets/json/driverless.json updated without manual intervention.
Changes:
- Add a scheduled (
cron: '0 6 1 * *') + manual (workflow_dispatch) workflow to rundriverless/update-printer-list.sh. - Validate the updated JSON and enforce a minimum “plausible” printer count before opening a PR.
- Auto-open/update a PR limited to
public/assets/json/driverless.jsonviapeter-evans/create-pull-request@v8.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+37
to
+50
| python3 - <<'PY' | ||
| import json, sys | ||
| try: | ||
| with open('public/assets/json/driverless.json') as f: | ||
| data = json.load(f) | ||
| except Exception as e: | ||
| print(f'::error::driverless.json is not valid JSON ({e}). Aborting.') | ||
| sys.exit(1) | ||
| count = sum(1 for p in data if p.get('model') != '_dummy_') | ||
| print(f'Driverless printers: {count}') | ||
| if count < 5000: | ||
| print(f'::error::driverless.json has only {count} printers; expected thousands. Aborting.') | ||
| sys.exit(1) | ||
| PY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #229.
Adds a scheduled GitHub Actions workflow that keeps the driverless (AirPrint +
IPP Everywhere) printer list up to date automatically, instead of relying on
manual runs.
driverless/update-printer-list.shon the 1st of each month(
cron: '0 6 1 * *'), with aworkflow_dispatchtrigger for manual runs.peter-evans/create-pull-request@v8,scoped to
public/assets/json/driverless.json.plausible number of printers before opening a PR, so an upstream failure can't
empty the list again (see No Driverless Printers? #223).
The auto-opened PR uses the default
GITHUB_TOKENand therefore won't run thebuild.ymlchecks; merging still triggers the Pages deploy.