AI Hints
Home›Git & GitHub Tutorial›GitHub Pages and Actions
Git & GitHub · Lesson 110 of 144

GitHub Actions

Automation on every push.

⏱ 2 min read▶ Video at 2:00:29🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

GitHub Actions runs tasks for you, automatically, whenever something happens in your repository. Like running tests on every push, or checking every pull request before it's merged.

GitHub Actions
From the video: GitHub Actions
  • Automatic tasks
  • Triggered by pushes and pull requests
  • Tests, checks, deploys

Key words

A few words to know. A workflow is a file describing the automation. An event is what triggers it, like a push. A job is a group of steps that runs on a fresh virtual machine, called a runner. And steps are the individual commands.

Workflowa YAML file
Eventpush, pull_request
Jobruns on a runner
Stepsthe commands

Your first workflow

Workflows live in a folder called dot github slash workflows. This one is named check site. It runs on every push to main, and on every pull request. It has one job, called check, on an ubuntu machine. The first step checks out our code. The second step runs a small script, check dot SH, that fails if any page is missing a heading.

.github/workflows/check.ymlyaml
name: Check site

on:
  push:
    branches: [main]
  pull_request:

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Check every page has a title
        run: sh check.sh

Summary

GitHub Actions runs workflows, written in YAML, on events like push and pull request. Next, seeing the results.

Key takeaways
  • .github/workflows/*.yml
  • on: push, pull_request
  • jobs and steps
Next up: Checks on Pull Requests — green ticks and red crosses