Skip to main content
Developer Tools

GitHub Actions CI/CD Workflows

Essential

YAML workflow syntax, matrix builds, automated testing, artifact publishing, caching, and repository secrets injection.

Instant Copy & SearchProduction Flagged SyntaxCurrent Flag Reference

GitHub Actions CI/CD Workflows Interactive Command Directory

Browse, search, and copy battle-tested commands & syntax recipes (15 Total Commands).

15+ Verified Recipes
Triggerson:
on: push: branches: [main] pull_request: branches: [main]

Define events that trigger workflow runs on code push and pull requests.

Repository Checkoutactions/checkout@v4
- uses: actions/checkout@v4 with: fetch-depth: 0

Check out the repository codebase with full commit history for versioning tools.

Node Setup & Cachingactions/setup-node@v4
- uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm'

Provision Node.js runtime and automatically restore/save npm dependency cache.

Matrix Buildsstrategy.matrix
strategy: matrix: node: [18, 20, 22] os: [ubuntu-latest, macos-latest]

Execute parallel jobs across multiple combinations of runtime versions and operating systems.

Secrets & Environment${{ secrets.* }}
env: DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }} API_KEY: ${{ secrets.STRIPE_SECRET }}

Inject encrypted organization or repository secrets safely into job environment.

Concurrency Controlconcurrency
concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true

Automatically cancel redundant in-progress CI builds when new commits are pushed.

Step Dependenciesneeds:
jobs: deploy: needs: [test, lint, build]

Enforce dependency ordering so deployment job only executes after test suite succeeds.

Artifact Uploadactions/upload-artifact@v4
- uses: actions/upload-artifact@v4 with: name: production-bundle path: dist/ retention-days: 7

Persist built assets and test reports between jobs or for manual download.

Workflow Triggerson: [push, pull_request]
on: push: branches: [main] pull_request: types: [opened, synchronize]

Trigger automated CI pipeline on direct pushes to main and on pull request creation/commits.

Caching & Performanceuses: actions/cache@v4
- name: Cache Dependencies uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

Cache package dependencies across runs using cryptographic lockfile hashes to cut build times by 70%.

Matrix Buildsstrategy.matrix
strategy: matrix: node-version: [18.x, 20.x, 22.x] os: [ubuntu-latest, macos-latest]

Run automated test suites concurrently across multiple language runtimes and operating systems.

Artifactsuses: actions/upload-artifact@v4
- name: Upload Test Report uses: actions/upload-artifact@v4 with: name: playwright-report path: playwright-report/ retention-days: 7

Upload build outputs, test coverage HTML reports, or compiled binaries for developer download.

OIDC Cloud Authpermissions.id-token: write
permissions: id-token: write contents: read # Authenticate to AWS/GCP without long-lived secret keys

Request an OpenID Connect (OIDC) JWT token to assume IAM roles in AWS or GCP without storing permanent API keys in repository secrets.

CLI Managementrun list
gh run list --workflow=ci.yml --limit 10

List the status, branch, and execution duration of recent workflow runs from the terminal using GitHub CLI.

CLI Debugging--log-failed
gh run view <run-id> --log-failed

Download and print only the failed step logs from a broken GitHub Actions workflow run.

Zero Setup100% In-Browser Execution

Companion Developer Tools & Playgrounds

Accelerate command execution and syntax debugging with HelloAIHub suite of interactive tools.

Explore all developer tools

GitHub Actions CI/CD Workflows: Command Groups & Quick Index

15 indexed entries across 14 sections
Triggers1 items
Repository Checkout1 items
Node Setup & Caching1 items
Matrix Builds2 items
Secrets & Environment1 items
Concurrency Control1 items
Step Dependencies1 items
Artifact Upload1 items
Workflow Triggers1 items
Caching & Performance1 items
Artifacts1 items
OIDC Cloud Auth1 items
CLI Management1 items
CLI Debugging1 items

Highlighted Flags & Syntax Examples in GitHub Actions CI/CD Workflows

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

Define events that trigger workflow runs on code push and pull requests.

Flags: on:
- uses: actions/checkout@v4 with: fetch-depth: 0

Check out the repository codebase with full commit history for versioning tools.

Flags: actions/checkout@v4
- uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm'

Provision Node.js runtime and automatically restore/save npm dependency cache.

Flags: actions/setup-node@v4
strategy: matrix: node: [18, 20, 22] os: [ubuntu-latest, macos-latest]

Execute parallel jobs across multiple combinations of runtime versions and operating systems.

Flags: strategy.matrix

Frequently Asked Questions

Expert recommendations, common traps, and production best practices for GitHub Actions CI/CD Workflows.

What is the difference between GITHUB_TOKEN and Personal Access Tokens (PAT)?

GITHUB_TOKEN is an automatically generated, short-lived secret scoped only to the repository running the action. A PAT is a personal user credential that persists across repositories and requires manual secret rotation.

How can I debug a failing GitHub Actions workflow locally?

You can use 'act' (a community tool that runs GitHub Actions workflows locally inside Docker containers) or add an SSH debugging action like 'tmate' to attach an interactive terminal session directly to the runner.

What is the difference between repository secrets and environment secrets in GitHub Actions?

Repository secrets are available to all workflows across all branches. Environment secrets are bound to a specific deployment environment (e.g. production) and can enforce manual approval gates, required reviewers, and branch protection restrictions before unveiling secrets.

How do composite actions differ from reusable workflows in GitHub Actions?

Composite actions bundle multiple bash shell steps into a single reusable action within the same job. Reusable workflows allow an entire multi-job workflow file (.github/workflows/deploy.yml) to be invoked as a sub-workflow from another workflow.

How can I test GitHub Actions workflows locally before pushing?

You can use act (nektos/act), an open-source tool that reads your local .github/workflows/ files and executes jobs inside local Docker containers matching GitHub runner environments.

What happens if a GitHub Actions job exceeds runner resource limits?

Standard GitHub-hosted Linux runners provide 2 vCPUs, 7 GB RAM, and 14 GB SSD space. If a build exceeds memory limits, the kernel OOM killer terminates the runner with exit code 137. You must enable swap space or switch to larger self-hosted runners.

Cross-Hub Skill Acceleration

Combine command lookups with active coding interviews and complete career paths.

Need More Cheat Sheets?

Explore developer cheat sheets and syntax guides on HelloAIHub.

Browse All Cheat Sheets