Generate a GitHub Actions workflow template for tests, builds, releases or scheduled jobs, with explicit permissions, caching and actions pinned to a version.
Node.js — install, lint and test · checked against this site's own workflow inspector
3 notes, all of which depend on what the repository is for.
Actions are pinned to a tag. A tag can be moved to a different commit by whoever publishes it, so a commit SHA is strictly stronger. For actions published by GitHub itself a major tag is a reasonable trade; for anything else the SHA is worth it.
Every template starts at permissions: contents: read and widens only where a job needs more. Without a permissions block the token gets the repository default, which on older repositories is write access to everything.
# A starting point, not a finished workflow. Review it before relying on it:
# runner versions, cache keys and deploy targets all depend on your repository.
name: Test
on:
push:
branches: [main]
pull_request:
# One run per branch. A new push cancels the one still going,
# which is what stops a busy branch queueing six identical runs.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Read-only by default; widen it on the job that needs more.
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm testChecked against this site's workflow inspector: no warnings. Permissions are declared, nothing untrusted reaches a shell, and every job has a runner.
A template, not a finished workflow — the first line of the output says so. Runner versions, cache keys, build and test script names, and deploy targets all depend on your repository, and the action versions are the ones current when this was written. Save it under .github/workflows/ and read it before relying on it.
GitHub Actions Workflow Generator runs entirely on your device — nothing is uploaded.
You’re on the Free plan. Compare plans
Every workflow here sets `permissions` explicitly, because the default grants the job's token more than it needs and a compromised step inherits all of it. Read-only is the baseline; anything more is listed with a reason beside it.
A `concurrency` group with `cancel-in-progress` is included, which is the most mundane and most valuable line in a workflow. Without it, three pushes to the same branch run three times and you wait for all of them. With it, the older runs are cancelled.
Dependency caching is wired up per ecosystem, because it is the difference between a two-minute job and a six-minute one, and getting the cache key right is the fiddly part — it must include the lockfile hash or the cache goes stale without ever missing.
Every action is pinned to a major version at least. The page explains why pinning to a commit SHA is stronger: a tag can be moved, and moving a popular action's tag is a supply-chain attack that has happened. SHA pinning costs you automatic updates, which is a real trade-off and stated as one.
**These are templates and need review before use.** They are not guaranteed to work in your repository — paths, build commands, required secrets and branch names are all project-specific. Nothing is executed, no GitHub API is called, and no token is involved.
Because the default token is broader than most jobs need, and every step in the job inherits it — including a compromised dependency. Starting from `contents: read` and adding only what a job genuinely needs limits what goes wrong when something does.
It is stronger than a tag, because a tag can be moved to point at different code and that has been used as an attack. The cost is that you no longer get patches automatically, so the choice depends on whether you have something like Dependabot keeping the pins current.
Cancels in-progress runs for the same ref when a new one starts. Push three times in five minutes and you get one run instead of three, which saves both your minutes and your waiting.
Not necessarily — it is a template. Build commands, paths, secret names and branch names are all project-specific. Read it, adapt it, and expect the first run to need a fix.
No. There is no API call, no token and no authentication anywhere in this phase. The workflow is generated as text in your browser.