GitHub Actions reference

GitHub Actions reference

GitHub Actions workflows live under `.github/workflows/*.yml`. Every workflow is a YAML document with three required top-level pieces: a `name:`, a set of triggers under `on:`, and a map of `jobs:`. Each job declares the runner image (`runs-on:`), an optional list of dependencies (`needs:`), and a list of steps. Steps are either a shell command (`run:`) or a reusable Action (`uses: org/action@version`).

Expressions in GitHub Actions use the `${{ ... }}` syntax and pull values from contexts: `github` (repository / event metadata), `secrets` (repository / org-level secrets), `vars` (variables), `env` (environment), and `matrix` (when inside a matrix job).

Top-level keys

KeyPurpose
nameDisplay name of the workflow.
onTrigger configuration: push, pull_request, schedule, workflow_dispatch, etc.
permissionsGITHUB_TOKEN scopes for the workflow.
envWorkflow-level environment variables.
concurrencyGroup + cancel-in-progress controls.
jobsMap of job-id → job definition.
jobs.<id>.runs-onRunner label or self-hosted matcher.
jobs.<id>.stepsOrdered list of run / uses steps.
jobs.<id>.strategy.matrixMatrix expansion of the job.
jobs.<id>.environmentDeployment environment (with required-reviewer gating).
jobs.<id>.containerRun all steps inside this Docker image.
jobs.<id>.servicesSidecar service containers (e.g. postgres).

Minimal example

name: CI
on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test

Context variables

The same concept goes by a different name on every platform. Use this table when porting expressions and conditions.

ConceptGitHub ActionsGitLab CICircleCIBitbucket
Branch namegithub.ref_name$CI_COMMIT_REF_NAME<< pipeline.git.branch >>$BITBUCKET_BRANCH
Commit SHAgithub.sha$CI_COMMIT_SHA<< pipeline.git.revision >>$BITBUCKET_COMMIT
Tag namegithub.ref_name$CI_COMMIT_TAG<< pipeline.git.tag >>$BITBUCKET_TAG
Repository sluggithub.repository$CI_PROJECT_PATH<< pipeline.project.git_url >>$BITBUCKET_REPO_FULL_NAME
Run / pipeline idgithub.run_id$CI_PIPELINE_ID<< pipeline.id >>$BITBUCKET_BUILD_NUMBER
Triggering eventgithub.event_name$CI_PIPELINE_SOURCE<< pipeline.trigger_source >>(implicit; check pipelines.* section)
Actor / usergithub.actor$GITLAB_USER_LOGIN$CIRCLE_USERNAME$BITBUCKET_STEP_TRIGGERER_UUID
Workspace pathgithub.workspace$CI_PROJECT_DIR$CIRCLE_WORKING_DIRECTORY$BITBUCKET_CLONE_DIR
PR / MR source branchgithub.head_ref$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME$CIRCLE_BRANCH (head ref)$BITBUCKET_PR_DESTINATION_BRANCH (target only)
PR / MR target branchgithub.base_ref$CI_MERGE_REQUEST_TARGET_BRANCH_NAME(not directly exposed)$BITBUCKET_PR_DESTINATION_BRANCH

Related Tools