← Level 6 – Project lead

Lesson 5 of 8 ⏱ 35 minutes Premium

Automatic Deployment

Set up GitHub Actions: push a change and the website updates itself. Like the pros.

Robots do the work for you

Right now it works like this: you change the code → commit → push → GitHub Pages updates. That’s already automation! But the pros go further – GitHub Actions is a robot that, after every push, does whatever you tell it to: build the website, check for errors, deploy.

This is called CI/CD (continuous integration / continuous deployment). It sounds complicated, but it’s really just: “Robots check and deploy everything after every change.”

Show me: your first workflow

Tasks for robots are written into a file inside the .github/workflows/ folder. For example, deploy.yml:

name: Check and deploy

on:
  push:
    branches: [main]   # run after every push to main

jobs:
  check:
    runs-on: ubuntu-latest   # the robot gets a clean Linux computer
    steps:
      - uses: actions/checkout@v4      # download my code
      - name: Check HTML
        run: |
          echo "Checking that index.html exists…"
          test -f index.html && echo "OK ✅"

After a push, a running robot shows up on GitHub under the Actions tab. A green checkmark means everything passed; a red X means something’s wrong, and the robot will tell you what.

💡

GitHub Pages already uses Actions! If you look at the Actions tab, you’ll see that deploying Pages runs through a workflow called “pages build and deployment”. You’re now adding your own extra checks on top – like a real boss who won’t let a broken version go live.

Now it’s your turn 💪

  1. Create .github/workflows/deploy.yml following the example, push it, and watch the Actions tab.
  2. Break something on purpose: rename index.html to index2.html, push – the workflow turns red. Fix it and watch it turn green. (This is the most important experience of this lesson!)
  3. Add a second step to the workflow – checking that no localhost was left in the HTML:
      - name: No localhost in the code
        run: |
          if grep -r "localhost:3000" *.html; then
            echo "WARNING: localhost was left in the code!" && exit 1
          fi
          echo "OK ✅"
  1. Write in LAUNCH.md: “The website deploys automatically, a robot checks every push.”

Check: Your workflow runs in the Actions tab after every push. You’ve seen both red (broken) and green (fixed). The website updates without a single manual step.

What to take away from this lesson