mirror of
https://github.com/duthaho/claudekit.git
synced 2026-06-10 12:14:57 +03:00
1.4 KiB
1.4 KiB
GitHub Actions
Description
GitHub Actions CI/CD workflows including testing, building, and deployment.
When to Use
- Setting up CI/CD pipelines
- Automating tests and builds
- Deployment automation
Core Patterns
Basic CI Workflow
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 test
Matrix Builds
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: [18, 20]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
Caching
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: npm-
Secrets
- name: Deploy
env:
API_KEY: ${{ secrets.API_KEY }}
run: deploy --key "$API_KEY"
Best Practices
- Use caching for dependencies
- Run jobs in parallel when possible
- Use environment secrets
- Pin action versions
- Add proper triggers
Common Pitfalls
- Slow pipelines: Add caching
- Secret exposure: Never echo secrets
- Unpinned versions: Use @v4 not @main