⚡ 100% In-Browser & Private: Your data never leaves your computer. Powered by Cloudflare Edge CDN.
ProWebTools PRO
Developer & SEO Utilities
25+ Rules

GitHub Actions Workflow & CI/CD Cheat Sheet

Production GitHub Actions cheat sheet: push/pull_request triggers, matrix builds, encrypted secrets, actions/cache@v4, and artifact uploads with 1-click copy.

Triggers & Events (4 commands)

Triggers & Events
on: [push, pull_request]

Triggers workflow execution on any Git push or pull request to the repository.

PRO TIP Define specific branch filters (branches: [main, release/*]) to prevent extraneous builds.
Triggers & Events
on: workflow_dispatch: inputs: env: { description: "Target environment", required: true, default: "staging" }

Enables manual workflow triggering from GitHub Actions web UI with dropdown inputs.

PRO TIP Essential for manual production release approvals and scheduled maintenance tasks.
Triggers & Events
on: schedule: - cron: "0 2 * * 1-5"

Runs workflow automatically on a scheduled crontab expression in UTC time.

PRO TIP GitHub schedules execute on best-effort timing; avoid tight second-level dependency.
Triggers & Events
on: push: paths: - "src/**" - "!src/**/*.test.ts"

Triggers workflow only when committed files match specific glob patterns.

PRO TIP The exclamation mark prefix ignores doc and test file changes from triggering full CI.

Matrix & Runners (3 commands)

Matrix & Runners
runs-on: ubuntu-latest

Executes job steps on GitHub-hosted Ubuntu Linux virtual machine runner.

PRO TIP Also supports windows-latest, macos-latest, or self-hosted enterprise runners.
Matrix & Runners
strategy: matrix: node-version: [18.x, 20.x, 22.x] os: [ubuntu-latest, windows-latest]

Spawns a multi-dimensional matrix of parallel runner combinations.

PRO TIP Pass fail-fast: false to prevent one matrix failure from cancelling other ongoing runs.
Matrix & Runners
environment: name: production url: https://example.com

Binds workflow to a protected GitHub Environment requiring reviewer approval.

PRO TIP Environment secrets cannot be accessed until designated team leads click Approve.

Steps & Caching (3 commands)

Steps & Caching
- uses: actions/checkout@v4 with: fetch-depth: 0

Clones repository code into runner. fetch-depth: 0 retrieves full git commit history.

PRO TIP Full git history is required for changelog generators, release tags, and SonarQube.
Steps & Caching
- uses: actions/setup-node@v4 with: node-version: 20 cache: "npm"

Provisions Node.js runtime and automatically restores ~/.npm dependency cache.

PRO TIP Built-in cache speeds up npm install / npm ci by 60-80%.
Steps & Caching
- uses: actions/cache@v4 with: path: ~/.cache key: ${{ runner.os }}-cache-${{ hashFiles("**/lock.json") }}

Caches custom directories across workflow runs using cryptographic file hash keys.

PRO TIP Specify restore-keys for fallback prefix matches when exact lockfile key misses.

Secrets & Contexts (3 commands)

Secrets & Contexts
env: API_KEY: ${{ secrets.PROD_API_KEY }} APP_ENV: ${{ vars.DEPLOY_ENV }}

Injects encrypted repository secrets and plain configuration variables into environment.

PRO TIP GitHub masks secret values automatically from workflow terminal log output.
Secrets & Contexts
if: github.ref == "refs/heads/main" && success()

Conditional step execution based on git branch and previous step exit statuses.

PRO TIP Use always() to run notification or cleanup steps even if previous steps failed.
Secrets & Contexts
- uses: actions/upload-artifact@v4 with: name: release-build path: dist/

Uploads build artifacts (bundles, zip files, test reports) downloadable from the UI.

PRO TIP Artifacts can be retrieved in downstream jobs using actions/download-artifact@v4.