GitHub Actions — встроенный CI/CD в GitHub (free 2000 min/мес для private repos, unlimited для public). Workflow = YAML файл в .github/workflows/. Triggers: push, pull_request, schedule (cron), manual. Runners: ubuntu-latest, macos-latest, windows-latest. Deploy через SSH + rsync, docker push, Vercel/Netlify integrations. Secrets хранятся в repo settings.
Ниже: пошаговая инструкция, рабочие примеры, типичные ошибки, FAQ.
.github/workflows/ci.ymlon: push: branches: [main]| Сценарий | Конфиг |
|---|---|
| Simple Node.js CI | name: CI
on:
push: { branches: [main] }
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npm test |
| Deploy via SSH | deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: deploy
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: cd /var/www && git pull && npm install --production && pm2 reload all |
| Matrix build (multi Node version) | strategy:
matrix:
node: [18, 20, 22]
steps:
- uses: actions/setup-node@v4
with: { node-version: ${{ matrix.node }} } |
| Docker build + push | - uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }} |
| Scheduled workflow (cron) | on:
schedule:
- cron: '0 2 * * *' # daily at 2 AM UTC |
::add-mask:: или sensitive steps с if: env checkif: github.ref == 'refs/heads/main'Для solo проекта — да. Team 5+ — иногда нужен Teams $4/user/мес или self-hosted runners.
Для private network access, unlimited minutes, GPU/ARM runners. Downside — maintenance + security (compromised runner = RCE в GitHub workflow).
Secrets — encrypted, not visible в logs. Env vars — plain, visible. Для tokens/passwords — всегда secrets.
GitHub Actions: free для GH repos, огромная marketplace actions, YAML. Jenkins: self-host, flexible но maintenance. GitLab CI: tight GitLab integration. Для GitHub — Actions default.