jlumbroso/Hugo Canvas Sync
Scan a Hugo site for canvas-file shortcodes, upload new/changed files to Canvas LMS, commit canvas_urls.json, and optionally run a second Hugo build so authenticated Canvas URLs are baked into the deployment.
View on GitHubTrust Signals
- Scorecard Score
- not yet scored
- Maintenance Recency
- Stale
- License
- None
Inputs
| name | description | required | default |
|---|---|---|---|
| canvas_api_url | Canvas API base URL (e.g. https://canvas.upenn.edu). Store as a GitHub secret. | yes | — |
| canvas_api_key | Canvas API token. Create one in Canvas → Account → Settings → Approved Integrations → New Access Token. Store as a GitHub secret. | yes | — |
| canvas_course_id | Integer ID of the Canvas course (from the Canvas course URL: /courses/<id>). | yes | — |
| hugo_root | Path to the Hugo site root (relative to the repo root). | no | . |
| data_file | Path to canvas_urls.json relative to hugo_root. This file is committed so Canvas URLs persist between builds. | no | data/canvas_urls.json |
| persistence_strategy | How canvas_urls.json is persisted between CI runs. "main" — commit the file to the current branch (simplest; O(1) git noise) "branch" — commit to a dedicated branch (clean main history; sparse-checkout required) "cache" — GitHub Actions cache only (no git noise; lost on cache eviction → safe re-upload) Recommendation: start with "main". Use "branch" if you want zero commits on your primary branch. | no | main |
| canvas_data_branch | Branch name for the "branch" persistence strategy. | no | canvas-data |
| auto_commit | Automatically commit and push canvas_urls.json after sync. Requires permissions: contents: write in the calling workflow. | no | true |
| run_hugo_rebuild | Run a second `hugo` build after the sync so Canvas URLs are injected into the final site. Set to "false" if you want to run hugo yourself. | no | true |
| hugo_build_flags | Flags passed to `hugo` for the second build. | no | --gc --minify |
| hugo_environment | Hugo environment for the second build (sets hugo.Environment). | no | production |
| install_hugo | Install Hugo automatically using peaceiris/actions-hugo before the rebuild. Set to "true" for zero-config; leave "false" if you install Hugo yourself. | no | false |
| hugo_version | Hugo version to install when install_hugo is "true". | no | latest |
| hugo_binary | Absolute path to the hugo binary. Overrides PATH lookup and install_hugo. Useful in monorepos or custom environments. | no | "" |
| dry_run | Scan and log what would be uploaded without actually uploading. | no | false |
| python_version | Python version to use (minimum 3.9). | no | 3.11 |
| package_version | Override the version of hugo-canvas-sync to install. Defaults to latest stable from PyPI. | no | "" |
Outputs
| name | description |
|---|---|
| files_uploaded | Number of files uploaded in this run. |
| files_skipped | Number of files skipped (hash unchanged). |
| files_failed | Number of files that failed to upload. |