GitHub Actions Cheatsheet

Events and Triggers

Use this GitHub Actions reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.

Push and Pull Request

on:
  push:
    branches: [main, develop]
    branches-ignore: ['dependabot/**', 'renovate/**']
    tags: ['v*.*.*']
    paths: ['src/**', 'package.json']
    paths-ignore: ['**.md', 'docs/**']

  pull_request:
    branches: [main]
    types: [opened, synchronize, reopened, ready_for_review]
    paths: ['src/**']

  pull_request_target:   # Runs in context of BASE branch (access to secrets)
    types: [opened, synchronize]

pull_request_target has write access and secrets — validate all user inputs carefully.

Schedule (Cron)

on:
  schedule:
    - cron: '0 6 * * 1-5'   # 6 AM UTC Mon–Fri
    - cron: '0 0 * * 0'     # Midnight UTC every Sunday

Cron field order: minute hour day-of-month month day-of-week

ExampleMeaning
0 * * * *Every hour
*/15 * * * *Every 15 minutes
0 8 * * 1-58 AM UTC weekdays
0 0 1 * *Midnight on the 1st of each month
0 12 * * 0Noon UTC every Sunday

Scheduled workflows only run on the default branch and may be delayed up to 15 min under high load.

Manual Triggers — workflow_dispatch

on:
  workflow_dispatch:
    inputs:
      environment:
        description: 'Deployment target'
        required: true
        type: choice
        options: [dev, staging, production]
        default: staging
      debug:
        description: 'Enable debug logging'
        type: boolean
        default: false
      version:
        description: 'Release version (e.g. 1.2.3)'
        type: string
        required: false

Access inputs:

- run: echo "Deploying to ${{ inputs.environment }}"
- if: ${{ inputs.debug }}
  run: set -x && env

Trigger via CLI:

gh workflow run deploy.yml \
  --ref main \
  -f environment=staging \
  -f debug=true

Workflow Call — workflow_call

on:
  workflow_call:
    inputs:
      environment:
        required: true
        type: string
    secrets:
      deploy-key:
        required: true
    outputs:
      url:
        description: 'Deployed URL'
        value: ${{ jobs.deploy.outputs.url }}

Repository Events

EventTriggered when
pushCommits pushed to a branch or tag
pull_requestPR opened, updated, closed, etc.
pull_request_reviewReview submitted/dismissed
createBranch or tag created
deleteBranch or tag deleted
releaseRelease published/created/edited
issuesIssue opened, closed, labeled, etc.
issue_commentComment on issue or PR
discussionGitHub Discussion events
forkRepo forked
starRepo starred (type: created)
watchRepo watched
gollumWiki page created/edited

Workflow and Check Events

EventTriggered when
workflow_dispatchManually triggered via UI or CLI
workflow_callCalled from another workflow
workflow_runAnother workflow completes
check_runCheck run created/completed
check_suiteCheck suite completed
statusCommit status changes
deploymentDeployment created
deployment_statusDeployment status updates

workflow_run — React to Another Workflow

on:
  workflow_run:
    workflows: ['CI Build']
    types: [completed]
    branches: [main]

jobs:
  deploy:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - run: echo "CI passed, deploying..."

External / API Triggers — repository_dispatch

on:
  repository_dispatch:
    types: [deploy-request, data-refresh]

Trigger via API:

curl -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  https://api.github.com/repos/OWNER/REPO/dispatches \
  -d '{"event_type":"deploy-request","client_payload":{"env":"prod"}}'

Access payload:

- run: echo "${{ github.event.client_payload.env }}"

Activity Types Reference

# pull_request types
types: [opened, edited, closed, reopened, synchronize,
        assigned, unassigned, labeled, unlabeled,
        ready_for_review, converted_to_draft,
        review_requested, review_request_removed, auto_merge_enabled]

# issues types
types: [opened, edited, deleted, closed, reopened,
        labeled, unlabeled, assigned, unassigned]

# release types
types: [published, created, edited, deleted,
        prereleased, released, unpublished]

Filter Patterns

# Glob patterns supported everywhere
branches:
  - main
  - 'release/v[0-9]+.[0-9]+'   # regex-like
  - 'feature/**'                 # any depth

paths:
  - 'src/**'
  - '!src/**/*.test.ts'          # exclude with !
  - 'package*.json'

tags:
  - 'v*'
  - '!v*-beta'