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_targethas 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 SundayCron field order: minute hour day-of-month month day-of-week
| Example | Meaning |
|---|---|
0 * * * * | Every hour |
*/15 * * * * | Every 15 minutes |
0 8 * * 1-5 | 8 AM UTC weekdays |
0 0 1 * * | Midnight on the 1st of each month |
0 12 * * 0 | Noon 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: falseAccess 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=trueWorkflow 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
| Event | Triggered when |
|---|---|
push | Commits pushed to a branch or tag |
pull_request | PR opened, updated, closed, etc. |
pull_request_review | Review submitted/dismissed |
create | Branch or tag created |
delete | Branch or tag deleted |
release | Release published/created/edited |
issues | Issue opened, closed, labeled, etc. |
issue_comment | Comment on issue or PR |
discussion | GitHub Discussion events |
fork | Repo forked |
star | Repo starred (type: created) |
watch | Repo watched |
gollum | Wiki page created/edited |
Workflow and Check Events
| Event | Triggered when |
|---|---|
workflow_dispatch | Manually triggered via UI or CLI |
workflow_call | Called from another workflow |
workflow_run | Another workflow completes |
check_run | Check run created/completed |
check_suite | Check suite completed |
status | Commit status changes |
deployment | Deployment created |
deployment_status | Deployment 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'