Getting Started with GitHub Actions
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
GitHub Actions is the automation platform built into GitHub. A repository declares workflows as YAML files; GitHub
starts them when an event happens (a push, a pull request, a schedule, a button click) and runs their jobs on
runners. Everything on this page is the common ground for the rest of the subsection: the vocabulary, a first working
workflow, how to watch it run, and how to check it before it ever reaches GitHub. The running example throughout is
this documentation site’s own publish.yml, which builds the Antora site every night and publishes it to GitHub
Pages. If Git itself is new, start at Git & GitHub.
The model
| Concept | Meaning |
|---|---|
Event |
Something that happens in (or to) the repository and can start a workflow: |
Workflow |
One YAML file in |
Job |
A group of steps that runs on one runner. Jobs run in parallel unless one declares |
Step |
One unit inside a job, either a shell command ( |
Action |
A reusable, versioned unit of automation referenced as |
Runner |
The machine that executes a job. GitHub-hosted runners are fresh virtual machines; self-hosted runners are your own. See Runners. |
Each job starts from a clean runner, so nothing carries over between jobs unless you pass it explicitly through job outputs or artifacts. Within a job, every step sees the files the previous steps created.
Your first workflow
Workflow files must live in .github/workflows/ at the repository root and end in .yml or .yaml. Create one on the
default branch (or any branch, for events that run from the branch itself):
# .github/workflows/hello.yml
name: hello
on:
push:
workflow_dispatch:
jobs:
greet:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Say hello
run: echo "Hello from $GITHUB_REPOSITORY at $GITHUB_SHA"
- name: List the repository
run: ls -la
Commit and push it:
mkdir -p .github/workflows
git add .github/workflows/hello.yml
git commit -m "Add hello workflow"
git push
The push trigger fires immediately, and workflow_dispatch adds a Run workflow button to the Actions tab. Without
actions/checkout, the runner has no copy of your repository: the step only checks out the code if you ask for it.
Where to see runs
The Actions tab
The repository’s Actions tab lists every workflow on the left and its runs on the right. Opening a run shows the
jobs, a graph of needs dependencies, each step’s log (with collapsible groups), annotations from ::error::
messages, the job summary and any uploaded artifacts. Failed runs offer Re-run failed jobs and Re-run all jobs;
a re-run can also enable debug logging.
The gh CLI
The GitHub CLI covers the same ground from a terminal:
gh workflow list # workflows in the repository and whether they are enabled
gh run list --workflow=hello.yml --limit 5
gh run view 1234567890 # summary of one run
gh run view 1234567890 --log # full log
gh run view 1234567890 --log-failed # only the failed steps
gh run watch 1234567890 --exit-status # follow live; non-zero exit if the run fails
gh workflow run hello.yml # trigger a workflow_dispatch workflow
gh run rerun 1234567890 --failed # re-run only failed jobs
Omit the run ID and gh run view or gh run watch offers an interactive picker.
Status badges
Every workflow has a badge URL of the form
https://github.com/<owner>/<repo>/actions/workflows/<file>.yml/badge.svg. Embed it in a README, optionally
selecting a branch or event:
[](https://github.com/albertoirurueta/docs/actions/workflows/publish.yml)
[](https://github.com/albertoirurueta/docs/actions/workflows/publish.yml?query=branch%3Amain)
The Create status badge entry in the workflow’s three-dot menu on the Actions tab generates the same markup.
Enabling, disabling and deleting
-
A workflow can be disabled from the Actions tab (the three-dot menu on a workflow) or with
gh workflow disable <name-or-file>;gh workflow enablereverses it. A disabled workflow keeps its file and history but no events start it. -
GitHub also disables scheduled workflows automatically in public repositories that have had no repository activity for a long period; re-enabling is a click or a
gh workflow enable. -
Repository (and organization) settings under Settings → Actions → General choose which actions may run (all, only your own, or an allow-list), the default
GITHUB_TOKENpermissions, and whether workflows from forks need approval. Those settings can only be tightened by an organization owner, never loosened below the organization’s policy. -
Deleting the YAML file removes the workflow from the list; old runs stay visible until deleted from the UI or with
gh run delete.
Billing and usage
The mechanism, without the price list (plans and rates change, so check GitHub’s current plan documentation):
-
Standard GitHub-hosted runners are free for public repositories.
-
Private repositories get an included allowance of minutes and storage per plan, and usage beyond it is billed. Minutes are counted per job, rounded up, and the multiplier depends on the runner’s operating system and size (Linux is the cheapest; macOS and larger runners cost more per minute).
-
Artifact and cache storage count toward storage limits; see the caching and artifacts page.
-
Self-hosted runners do not consume GitHub-hosted minutes, but you pay for the machines yourself.
-
Settings → Billing (or the organization’s equivalent) shows usage per repository, workflow and runner type, which is the quickest way to find an expensive workflow.
The practical consequence for design is simple: fewer, shorter jobs on Linux, with caching and cancelled superseded runs, cost the least. The same advice appears under the Runners page’s cost tips.
The running example: this site’s publish.yml
This site is built by Antora from the content.sources of antora-playbook.yml and deployed to the gh-pages
branch. Its nightly workflow, shown here in a trimmed form, is a complete if minimal pipeline:
name: publish # (1)
on:
schedule:
- cron: '0 3 * * *' # every day at 03:00 UTC
jobs:
publish: # (2)
runs-on: ubuntu-latest # (3)
steps:
- name: Checkout
uses: actions/checkout@v5 # (4)
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 24 # (5)
- name: Install Antora
run: | # (6)
npm i -D -E antora
npm i @antora/collector-extension
npm i @sntke/antora-mermaid-extension
npm i @djencks/asciidoctor-mathjax
- name: Validate Mermaid diagrams
run: |
npm i --no-save mermaid@11 jsdom
node scripts/validate-mermaid.mjs
- name: Build Antora docs
run: npx antora antora-playbook.yml
- name: Deploy to GitHub Pages
if: success() # (7)
uses: crazy-max/ghaction-github-pages@v5
with:
target_branch: gh-pages
build_dir: ./build/site
fqdn: www.irurueta.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # (8)
| Marker | Reading |
|---|---|
(1) |
|
(2) |
One job named |
(3) |
|
(4) |
Clone the repository at the triggering commit. The version after |
(5) |
|
(6) |
|
(7) |
|
(8) |
|
This workflow only triggers on a schedule (a twin manual_publish.yml has workflow_dispatch). The next pages show
how each topic would improve it: adding push and workflow_dispatch triggers, concurrency so two builds never
publish at once, an npm cache, a least-privilege permissions block, pinning actions to commit SHAs, deploying through
the github-pages environment, and moving the build into a reusable workflow.
Validating before pushing
A syntax error in a workflow is usually only discovered after a push, as a failed run with no jobs. Catch it locally:
# 1. Is it valid YAML at all?
python3 -c "import sys, yaml; yaml.safe_load(open(sys.argv[1]))" .github/workflows/publish.yml
# 2. Is it a valid workflow? (schema, expressions, shellcheck on run: scripts, action inputs)
actionlint # lints every file in .github/workflows
actionlint .github/workflows/publish.yml
# 3. Optional: run jobs locally in Docker
act -l # list jobs
act workflow_dispatch -j publish # run one job
-
actionlint (1.7.12 at the time of writing) understands the workflow schema, checks
${{ }}expressions and context names, and runsshellcheckoverrunscripts when it is installed. It is the one check worth adding to every repository, including as a CI step or a pre-commit hook. -
Plain YAML parsing only proves the indentation is well formed.
-
act runs workflows in Docker containers on your machine. It is useful for quick iteration on shell steps, but it is an approximation: its images are not the real runner images, and features such as OIDC, some contexts and hosted services behave differently. Treat a green
actas a hint, not proof.
Common mistakes
-
Putting the file in
.github/workflow/(singular) or outside.github/workflows/: nothing runs and nothing complains. -
Forgetting
actions/checkoutand then wondering why the repository is empty on the runner. -
Using tabs in YAML, or mis-indenting
with:so inputs are silently ignored. -
Expecting a
scheduleorworkflow_dispatchworkflow to run from a feature branch: both use the default branch’s copy of the file. -
Assuming files persist between jobs.