GitHub Actions Cache Matrices, CodeQL and GHCR Publishing
When to use
Use this builder when a repository is adding CI for the first time, or when an existing workflow has grown into a single job with no cache, one runtime version and broad write permissions.
It supports Node.js, Python, Go, Java and PHP. Each stack has an official setup action, a package manager default and a test command. I generate the skeleton first, then replace commands with what the repository actually runs.
It is not a deployment platform, a self-hosted runner template or a cross-cloud release pipeline. Those need environments, secrets and provider-specific authentication.
Steps
- Enter a workflow name and choose the stack and package manager. Switching stacks refreshes install, test, build and artifact defaults.
- Edit the version matrix and trigger branches. Node often tests 18, 20 and 22; Python starts at the oldest supported version.
- In the runtime and security card, set the job timeout and retention, then choose concurrency and CodeQL.
- Replace install, test and build commands with repository scripts, and fill the artifact path or GHCR image only when needed.
- Save the result under
.github/workflows/ci.yml, run it on a test branch, then merge to the main branch.
Screenshots

This is the default Node.js workflow. The right column shows on, permissions and jobs; the left column ends with the syntax and security checks.

After I enabled CodeQL, a security job appeared below the test job. It requests security-events: write, while the test job keeps read-only permissions.

This image focuses on the middle of the YAML. concurrency sits at the top level, timeout-minutes appears in each job, and retention is written under the artifact step.
Features in detail
Stack switching changes the setup action. Node uses setup-node@v4, and pnpm also inserts pnpm/action-setup@v4. Python uses setup-python@v5, Go uses setup-go@v5, Java uses setup-java@v4, and PHP uses setup-php@v2 with common extensions.
The matrix expands comma-separated versions into parallel jobs. fail-fast: false lets the remaining versions finish when one fails. Library projects usually test the oldest supported version and the latest LTS; applications follow the production runtime.
Caching is not a single boolean. Node writes a different cache field for npm, yarn and pnpm. Python switches among pip, poetry and uv. Go keys on go.sum. Java chooses between Maven and Gradle. A missing lock file causes repeated misses.
Artifact upload is off by default. When enabled, it writes if-no-files-found: error, so an empty or missing folder fails the job instead of uploading an empty package. Retention accepts 1–90 days and defaults to 7.
The image job runs only on a push to the first branch. It logs in to GHCR with GITHUB_TOKEN and tags the image with the commit SHA. The image name must be lowercase; uppercase characters are rejected by the registry.
CodeQL creates a separate job for Node.js, Python, Go and Java; compiled Go/Java jobs run autobuild before analysis. PHP is not supported, so the builder warns and skips the job. The scan runs only on same-repository branches; fork pull requests are excluded by an if guard.
What you get
The input includes a workflow name, stack, package manager, version matrix, branches, install/test/build commands, artifact path, image name, concurrency, CodeQL, timeout and retention.
The output is one YAML file. The top level has name, on, permissions and optional concurrency. jobs starts with test and may add docker and security. Every job has runs-on and timeout-minutes.
Copy writes the YAML to the clipboard. Download produces a .yml file. The filename is not tied to the repository, so name it by purpose, such as ci.yml or release.yml.
Parameters
| Control | Type | Default | Notes |
|---|---|---|---|
| Workflow name | text | CI | Written to name and used in the concurrency group |
| Stack | select | Node.js | Five options; decides the setup action |
| Package manager | select | npm | Changes with the stack |
| Version matrix | text | 18, 20, 22 | Comma or space separated |
| Trigger branches | text | main | Multiple branches allowed |
| Install command | text | npm ci | Written to run |
| Test command | text | npm test | Empty value omits the step |
| Build command | text | npm run build | Empty value omits the step |
| Artifact path | text | dist | Used when upload is enabled |
| Image name | text | ghcr.io/owner/app | Must be lowercase |
| Job timeout | number | 20 | 1–360 minutes |
| Artifact retention | number | 7 | 1–90 days |
Self-check list
- □
onhas at least one trigger, and branch names match the repository. - □ Top-level permissions are
contents: read; write scopes live inside specific jobs. - □ Matrix values are non-empty strings.
- □ The cache field matches the package manager and the lock file is committed.
- □ The artifact path exists after the build, and retention is between 1 and 90.
- □ CodeQL has
security-events: write, and fork PRs are excluded.
FAQ
Question: Why does the cache never hit? Answer: setup-node hashes the lock file. Without package-lock.json, yarn.lock or pnpm-lock.yaml, every run gets a different key.
Question: Why did CodeQL not run on a pull request? Answer: Fork PRs lack security-event write permission, so the workflow skips them. Run a scan on a same-repository branch before merging.
Question: What causes a 403 when pushing the image? Answer: Check the lowercase image name first, then Packages write permission under repository settings, then whether a narrower permission overrides GITHUB_TOKEN.
Question: Can concurrency cancel a deployment in progress? Answer: It groups by workflow and ref, so a new commit on the same branch cancels the old run. Give deployments a separate group or disable the switch.
Question: What timeout should I use? Answer: Start with 15–20 minutes for tests and 20–30 for image builds. Use the P95 of historical runs plus about 20 percent headroom.
Limits
The builder does not create repository secrets, configure environments or replace a deployment platform. It does not emit self-hosted runner labels, OIDC cloud login or reusable cross-repository workflows.
CodeQL covers four languages only. PHP needs composer audit or a third-party SAST tool. A scan is not proof of zero vulnerabilities; findings still need review in the Security tab.
GHCR is a default example. Docker Hub, a private registry or a cloud vendor registry requires replacing the login step and permissions together.
Design trade-offs
The generator appends YAML lines and joins the array with \n. A workflow with tests, an image and a scan is about 60–80 lines and renders in roughly one millisecond without network access.
I did not add a YAML library. Manual lines keep ${{ }} expressions literal and avoid serializing them into objects. The cost is that indentation is controlled by hand, so each block uses a fixed prefix.
Input is coalesced into one frame and identical signatures skip a rebuild. Typing commas into the matrix does not rebuild the whole file on every key, and copy always reads the last completed text. The generated text is also kept in a single state variable, so a copy action never has to re-run the generator or wait for a repaint after a click.
A second run with the same lock file reuses the setup action cache, while a new lock file creates a new key and a cold download. The generated job keeps the cache step before install, so a cache miss only costs one download rather than a full rebuild of every dependency. This ordering matters more on matrix runs, where three versions start at the same time and compete for the same network capacity.
Troubleshooting
Symptom: actionlint reports unexpected key "concurrency". The block was indented under jobs. Keep concurrency at the top level, next to permissions.
Symptom: a pnpm project fails with pnpm: not found. Only setup-node was added. Keep the generated pnpm/action-setup step and adjust its version.
Symptom: the artifact step fails with No files were found. The path points at source, or the build writes to another folder. Check locally with ls, then update path.
Diagnostic order: triggers and branches, matrix key names, setup and cache, then permissions and image name. Most indentation errors sit between lines 20 and 40.
Workflow and acceptance
Roll out in stages: tests only, then artifacts, then the image job, then CodeQL. Commit each stage separately so a failure has one obvious cause.
For team work, document the workflow name, branch and image in the repository. Update the matrix when the production runtime changes instead of leaving it for a year.
Acceptance: all three matrix versions pass; the second run logs a cache hit; the uploaded artifact downloads and unzips; CodeQL appears in the Security tab; the image job is skipped on a pull request.
Version and compliance
This release is 1.1.4 and follows ToolCMS plugin spec 3.19. The page does not read a repository, call the GitHub API or upload YAML. Everything is generated in the browser.
The output follows least privilege, but repository admins still review third-party action sources and versions. Before production, enable branch protection and require code review for workflow changes.