with one click
github-actions
// Provides patterns for building fast, reliable CI/CD workflows with GitHub-hosted runners including workflow syntax, caching, secrets, and reusable workflows.
// Provides patterns for building fast, reliable CI/CD workflows with GitHub-hosted runners including workflow syntax, caching, secrets, and reusable workflows.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | github-actions |
| description | Provides patterns for building fast, reliable CI/CD workflows with GitHub-hosted runners including workflow syntax, caching, secrets, and reusable workflows. |
Fast, reliable CI/CD workflows with GitHub-hosted runners. Core patterns for building production pipelines.
Sources: GitHub Actions Documentation (docs.github.com/en/actions), GitHub Actions Best Practices
Define workflows in .github/workflows/*.yml. Triggered by push, pull_request, schedule, or manual dispatch.
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: {node-version: 20, cache: npm}
- run: npm ci && npm test
Reference: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
push: Triggers on git push to branches/tagspull_request: Triggers on PR open, sync, reopenschedule: Cron syntax for scheduled runsworkflow_dispatch: Manual trigger from UIworkflow_call: Make workflow reusablePath filters: Run only when specific files change
on:
push:
paths: ['src/**', '!**/*.md']
Reference: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
Jobs run in parallel by default. Use needs for sequential execution. Steps run shell commands or reusable actions.
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: npm run build
deploy:
needs: build
if: github.ref == 'refs/heads/main'
steps:
- run: npm run deploy
Reference: https://docs.github.com/en/actions/using-jobs
Test multiple versions/platforms in parallel.
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, windows-latest]
runs-on: ubuntu-latest # Or use matrix.os variable
Reference: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
Cache node_modules, pip packages, or build outputs. Setup actions include built-in caching.
- uses: actions/setup-node@v4
with:
cache: npm # auto-caches node_modules
Manual caching:
- uses: actions/cache@v4
with:
path: ~/.npm
key: OS-node-HASH # Use: runner.os and hashFiles() variables
Reference: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows
Store sensitive data in repository/environment/organization secrets. Automatically masked in logs.
steps:
- run: echo "API_KEY_VALUE" # Use secrets.API_KEY variable
OIDC for cloud providers (preferred over static credentials):
Reference: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions
Define at workflow/job/step level.
env:
NODE_ENV: production
jobs:
build:
env:
API_URL: https://api.example.com
Reference: https://docs.github.com/en/actions/learn-github-actions/variables
Share workflows across repositories.
# .github/workflows/reusable.yml
on:
workflow_call:
inputs:
environment:
required: true
type: string
# Caller
jobs:
call:
uses: ./.github/workflows/reusable.yml
with:
environment: production
Reference: https://docs.github.com/en/actions/using-workflows/reusing-workflows
Code templates for this domain (in templates/):
github-workflow.yml — GitHub Actions CI/CD pipeline template