🔁 GitHub Actions cheat sheet
Workflow iskeleti
name: ci
on: [push, pull_request] | Tetikleyiciler |
on:
push:
branches: [main]
paths: ["src/**"] | Yola/dala göre |
on:
schedule:
- cron: "0 3 * * *" | Zamanlanmış |
on: workflow_dispatch | Elle tetikle |
jobs:
test:
runs-on: ubuntu-latest | Job ve runner |
Adımlar
- uses: actions/checkout@v4 | Kodu çek |
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm } | Node + cache |
- run: npm ci && npm test | Komut çalıştır |
- uses: docker/build-push-action@v6
with: { push: true, tags: ghcr.io/ben/app:${{ github.sha }} } | İmaj build/push |
- uses: actions/upload-artifact@v4 | Artifact yükle |
İleri
strategy:
matrix:
node: [18, 20] | Matris |
needs: [test] | Sıra bağımlılığı |
if: github.ref == 'refs/heads/main' | Koşullu |
env:
TOKEN: ${{ secrets.TOKEN }} | Secret kullan |
permissions:
contents: read | Token yetkisini daralt |
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true | Eskiyi iptal et |
environment: production | Onaylı ortam |
uses: org/repo/.github/workflows/dep.yml@v2 | Yeniden kullanılabilir workflow |