Snippets
GitHub Actions logo

GitHub Actions

GitHub Actions workflow snippets I ship to production. CI, scheduled jobs, releases, reusable workflows, and cost-saving tricks.

8

Cache npm Dependencies in GitHub Actions

Cache the npm store between GitHub Actions runs to cut install time from minutes to seconds. Lockfile-aware cache key included.

github-actionscachenpm+2
BEGINNERMay 16, 2026

Create a GitHub Release When a Version Tag is Pushed

A GitHub Actions workflow that creates a GitHub Release with auto-generated notes whenever a v* tag is pushed.

github-actionsreleasetag+2
INTERMEDIATEJun 13, 2026

GitHub Actions Matrix Build Across Node.js Versions

A matrix strategy that runs your test suite on multiple Node.js versions in parallel. Essential for libraries that support older Node releases.

github-actionsmatrixnodejs+2
INTERMEDIATEMay 4, 2026

Next.js CI Workflow with Lint, Typecheck, and Build

A clean GitHub Actions workflow for Next.js projects: install, lint, typecheck, build. Cached, fast, and PR-ready.

github-actionsnextjsci-cd+2
BEGINNERApr 12, 2026

Reusable GitHub Actions Workflow with workflow_call

Define a reusable Node.js setup workflow once and call it from any other workflow with workflow_call. Inputs, outputs, and secrets supported.

github-actionsworkflow-callreusable+2
INTERMEDIATEJun 5, 2026

Scheduled GitHub Actions Workflow Hitting a Secured Endpoint

A GitHub Actions cron that pings a bearer-auth endpoint every N minutes. Use it for scheduled revalidation, health checks, or webhooks.

github-actionscronschedule+2
INTERMEDIATEApr 24, 2026

Skip CI When Only Documentation Changed

Use a paths filter or dorny/paths-filter to skip GitHub Actions CI runs when a PR only touches Markdown or docs files.

github-actionspathsskip+2
BEGINNERJun 21, 2026

Sticky PR Preview Comment with github-script

Post or update a sticky comment on a pull request from GitHub Actions using actions/github-script. Perfect for preview links and build info.

github-actionspull-requestgithub-script+2
INTERMEDIATEMay 26, 2026

About these GitHub Actions snippets

These are workflow files I run in production repositories, not toy examples. Every snippet has been through the cycle of "it works on my machine" to "why did this fail at 3am" to "okay, now it actually works." The YAML you see here handles the edge cases the official docs skim over: caching gotchas, conditional execution, secret handling, and concurrency control.

All workflows target the latest GitHub-hosted runners (Ubuntu) and use pinned action versions with SHA hashes where it matters for supply chain safety.

What's inside

  • CI pipelines: a full Next.js CI workflow with lint, typecheck, and build in a single job, plus matrix builds across multiple Node.js versions for library testing.
  • Caching: npm dependency caching with proper cache key strategies, so your CI runs finish in seconds instead of minutes.
  • Releases: automated GitHub Releases triggered by semantic version tags, with changelog generation and artifact uploads.
  • Smart skipping: conditionally skip CI when only documentation files changed, saving runner minutes on docs-only PRs.
  • PR automation: post sticky preview comments on pull requests using github-script, with automatic updates on subsequent pushes.
  • Scheduled jobs: cron-based workflows that hit secured endpoints, useful for cache warming, health checks, and scheduled data syncs.

More workflows land here as I extract them from active repositories. If a workflow pattern saves CI minutes or prevents a class of deployment bugs, it ends up in this collection.

How to use them

Every snippet page shows the complete workflow YAML, explains the non-obvious parts, and lists the secrets and permissions you need to configure. Copy the YAML into .github/workflows/, set the required secrets in your repo settings, and push. The snippets are designed to work as standalone workflows. You can combine them, but each one is self-contained.

If you spot a cheaper way to run a job or a better caching strategy, the code is open on GitHub. PRs and issues are welcome.