DangKit
All Cheatsheets

GitHub Actions Cheat Sheet

# GitHub Actions Cheat Sheet ## Workflow Structure ```yaml name: CI on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: '20' } - run: npm ci - run: npm test ``` ## Triggers ```yaml on: push: branches: [main] pull_request: branches: [main] schedule: - cron: '0 0 * * *' workflow_dispatch: ``` ## Matrix Builds ```yaml strategy: matrix: node: [18, 20, 22] os: [ubuntu-latest, windows-latest] ``` ## Secrets ```yaml - run: echo ${{ secrets.MY_SECRET }} ``` ## Caching ```yaml - uses: actions/cache@v4 with: path: ~/.npm key: npm-${{ hashFiles('package-lock.json') }} ``` ## Reusable Workflows ```yaml jobs: call: uses: ./.github/workflows/reusable.yml with: { input: value } ```
DangKit โ€” 139+ Free Online Tools: PDF, Dev, Design, Finance & More