GitHub Actions Cheat Sheet

Workflow YAML snippets — triggers, jobs, secrets, and deploy patterns.

Related: github-actions · docker · kubernetes

Workflow skeleton

CommandDescription
name: CI on: push: branches: [main] pull_request: jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm ci && npm testBasic CI on push/PR
concurrency: group: deploy-${{ github.ref }} cancel-in-progress: trueCancel stale runs

Docker & registry

CommandDescription
- uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }}Login to GHCR
- uses: docker/build-push-action@v6 with: push: true tags: ghcr.io/org/app:${{ github.sha }}Build and push image

Deploy to K8s

CommandDescription
- uses: azure/setup-kubectl@v4 - run: kubectl apply -f k8s/ env: KUBECONFIG: ${{ secrets.KUBECONFIG_DATA }}Apply manifests (store kubeconfig as secret)
permissions: id-token: write contents: read # use aws-actions/configure-aws-credentials + EKS OIDCOIDC to cloud (no long-lived keys)