github-actions
Use when creating GitHub Actions workflows for CI/CD - testing, building, publishing npm packages, and automating repository tasks
When & Why to Use This Skill
This Claude skill empowers developers to architect and implement robust GitHub Actions workflows for seamless Continuous Integration and Continuous Deployment (CI/CD). It provides expert guidance on automating software lifecycles, including multi-platform testing, secure package publishing, and efficient repository task automation to enhance development velocity and code quality.
Use Cases
- Automated Testing: Configure CI pipelines to automatically run test suites across various Node.js versions and operating systems using matrix strategies to ensure cross-platform compatibility.
- Package Distribution: Streamline the release process by automating npm package publishing to registries, triggered securely by GitHub release events or manual dispatches.
- Build Optimization: Implement advanced caching strategies for dependencies and build artifacts to significantly reduce workflow execution time and resource consumption.
- Workflow Orchestration: Design complex delivery pipelines with conditional logic, job dependencies, and environment-specific configurations for controlled and reliable deployments.
| name | github-actions |
|---|---|
| description | Use when creating GitHub Actions workflows for CI/CD - testing, building, publishing npm packages, and automating repository tasks |
GitHub Actions
Quick Start
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
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
- run: npm run build
- run: npm test
Common Patterns
Matrix Testing
strategy:
matrix:
node-version: [18, 20, 22]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
npm Publishing
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Caching
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Triggers
| Event | Usage |
|---|---|
push |
On push to branches |
pull_request |
On PR open/update |
release |
On release publish |
workflow_dispatch |
Manual trigger |
schedule |
Cron schedule |
Key Features
# Conditional steps
- run: npm publish
if: github.event_name == 'release'
# Job dependencies
jobs:
build:
# ...
deploy:
needs: build
# Environment variables
env:
CI: true
NODE_ENV: test
# Secrets
${{ secrets.MY_SECRET }}
Tips
- Use
npm ci(notnpm install) for reproducible builds - Cache node_modules with
actions/setup-nodecache option - Use
workflow_dispatchinputs for manual parameters - Add
concurrencyto cancel in-progress runs on new pushes