GitHub Actions Workflow Generator

Generate a hardened .github/workflows file — or audit an existing one for unpinned actions, risky triggers and script injection

Branches for push / pull request, comma-separated

Always added: a read-only token by default and checkout without saving credentials.

.github/workflows/ci.yml
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: ["20", "22"]
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
        with:
          node-version: ${{ matrix.node-version }}
          cache: npm
      - run: npm ci
      - run: npm run lint
      - run: npm test
      - run: npm run build

Each action is pinned to the exact commit of its latest release (checked October 2026), with the version as a comment. A tag can be moved to different code — a commit can't. Version numbers in matrices are quoted on purpose — unquoted, YAML reads 3.10 as the number 3.1.

.github/dependabot.yml — keeps the pins up to date
version: 2
updates:
  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly
    groups:
      actions:
        patterns: ["*"]

Was the GitHub Actions Workflow Generator helpful?

Get new tools in your inbox

About once a month, when new tools ship. No spam, one-click unsubscribe.

We store only your email to send these updates. Privacy

About this tool

The ToolNinja GitHub Actions Workflow Generator builds a ready-to-commit CI workflow from a few choices: stack (Node.js, Python, Go, or a Docker image pushed to GitHub Container Registry), triggers, runner, version matrix, and which steps to run. The generated YAML pins each action (checkout, setup-node, setup-python, setup-go, and the Docker build actions) to the exact commit of its latest release, with the version as a comment — a tag can be moved to different code, as the 2025 tj-actions/changed-files compromise showed; a commit can't. Workflows get a read-only token by default and checkout without stored credentials, and a Dependabot file keeps the pins current. The Audit tab checks an existing workflow for the problems security scanners like zizmor report: unpinned actions, missing permissions, pull_request_target that runs a pull request's code, untrusted input such as PR titles inside run: scripts, tokens left on disk and self-hosted runners on pull requests — and it can pin every action to its commit for you. Dependency caching is set up where the setup action supports it, and version numbers in matrices are quoted so YAML doesn't read 3.10 as 3.1. The Docker option logs in to GHCR with the built-in GITHUB_TOKEN, tags images by branch, PR, and commit SHA, uses GitHub's build cache, and skips pushing on pull requests.

When to use it

  • →Adding CI to a new repository without writing workflow YAML from scratch
  • →Testing a Node or Python project across several runtime versions with a matrix
  • →Building and pushing a Docker image to GitHub Container Registry on every push
  • →Updating an old workflow to current action versions
  • →Auditing a workflow for supply-chain and script-injection risks before merging

Tips

  • ◆Save the file under .github/workflows/ in your repository; GitHub picks up any .yml file there automatically.
  • ◆Quote version numbers in YAML. Unquoted, 3.10 becomes the number 3.1 and you'll silently test the wrong Python version.
  • ◆For pnpm, add a "packageManager" field to package.json (for example "pnpm@10.0.0") so the pnpm setup action knows which version to install.

Frequently asked questions

Do I need to add any secrets?

Not for the Node, Python, and Go workflows. The Docker workflow uses the built-in GITHUB_TOKEN to push to GitHub Container Registry, which works without extra setup as long as the workflow has packages: write permission. The generated file includes that permission.

Why does the Docker workflow not push on pull requests?

Pull requests from forks don't get write access to your registry, and you usually don't want an image published for unmerged code. The workflow still builds on pull requests, so a broken Dockerfile fails CI before merge.

How do I run the workflow manually?

Enable the 'Manual (workflow_dispatch)' trigger. A 'Run workflow' button then appears on the workflow's page in the repository's Actions tab.

Related tools

ToolNinja