Trending
| 8:18 AM IST
GitHub Actions for Beginners: Let GitHub Test and Deploy Your Website Automatically (Part 19)
Tech

GitHub Actions for Beginners: Let GitHub Test and Deploy Your Website Automatically (Part 19)

GitHub Actions runs jobs for you whenever something happens in your repository: checks on every pull request, automatic deploys and scheduled tasks. Write your first workflow in Part 19 of our Git series.

By · 9 min read 3 views Rate it 0 comments

GitHub Actions is GitHub's built-in automation service. You write a small YAML file, called a workflow, in the .github/workflows folder of your repository. It tells GitHub to run jobs automatically when something happens, such as a push or a pull request. Typical jobs check code for errors, run tests and deploy websites. It is free for public repositories on standard runners.

One Friday evening, a pull request with a missing closing tag slipped past everyone at Sneha's studio. Ravi was tired, Anu was reviewing on her phone and Sneha approved in a hurry. Saturday morning, the hospital's appointment page rendered as a jumbled mess. "Humans get tired," Arjun said when she told him. "Let a robot check every pull request. It never gets tired." That robot is GitHub Actions. In Part 16 we protected main and required reviews, and in Part 18 we published a site with GitHub Pages. This Part 19 connects the two: automatic checks on every pull request, and automatic deploys when main changes, explained without assuming you are a DevOps expert.

Your one-minute summary

  • A workflow is a YAML file in .github/workflows/
  • An event (push, pull request, schedule) triggers it
  • A workflow has jobs; each job has steps
  • Jobs run on a runner, a fresh virtual machine provided by GitHub
  • Reuse ready-made actions from the GitHub Marketplace
  • Free for public repos; the Free plan includes 2,000 minutes a month for private repos

What is CI/CD, in simple words?

CI stands for continuous integration: automatically checking every change as soon as it is pushed. CD stands for continuous delivery or deployment: automatically publishing changes once they pass the checks. Think of a quality inspector on a factory line: every product is checked the same way, every time, without anyone forgetting, even on a Friday evening.

From push to live site, automatically

You push or open a PRThe event that starts everything
GitHub starts a runnerA fresh Linux, Windows or macOS machine
Checks runLint HTML/CSS, run tests, check links
Result on the PRGreen tick ✔ or red cross ✖
Deploy on mergeWhen main changes, publish the site

What are the building blocks of GitHub Actions?

GitHub's Understanding GitHub Actions guide describes five key pieces. Here they are with an everyday analogy: a school's daily routine.

PieceWhat it isSchool analogy
WorkflowThe whole automated process, in one YAML fileThe daily timetable
EventWhat starts it: push, pull_request, schedule, manualThe morning bell
JobA group of steps that run on one machineOne class period
StepA single command or reusable actionOne activity in that class
RunnerThe machine that does the workThe classroom

How the pieces nest

Workflowcheck.yml, the whole plan
Triggered by an eventon: push and pull_request
Jobhtml-check, running on ubuntu-latest
StepsGet the code, then run the HTML checker
Also readHost Your Website Free with GitHub Pages: Step-by-Step Guide (Part 18)

What does a first workflow look like?

Let us add the check that would have saved the studio's Saturday: on every push and pull request, GitHub downloads the code and checks the HTML for errors. Create a file at .github/workflows/check.yml with these lines (indentation matters in YAML, so use two spaces per level):

LineMeaning
name: Check websiteThe name shown in the Actions tab
on: [push, pull_request]Run on every push and every pull request
jobs:Start of the list of jobs
  html-check:A job called html-check
    runs-on: ubuntu-latestUse a fresh Ubuntu Linux runner
    steps:Start of the list of steps
      - uses: actions/checkout@v4Reusable action: download the repository's code
      - run: npx --yes htmlhint "**/*.html"Run a free HTML checker on every .html file

Commit and push the file. Open the Actions tab on GitHub and you will see the workflow running, with a live log of each step. If the HTML has problems, the job fails and shows exactly which file and line need attention.

Version numbers changeActions such as actions/checkout release new major versions over time. When you set up a workflow, check the action's page on GitHub Marketplace for the current recommended version, or start from one of GitHub's ready-made templates in the Actions tab.

How do checks appear on a pull request?

Once a workflow runs on pull_request, its result appears at the bottom of every PR: a yellow dot while running, a green tick when it passes and a red cross when it fails. Combined with the branch protection rule "Require status checks to pass" from Part 16, GitHub will not allow a merge until the checks are green. Broken HTML never reaches the live site again.

What a pull request shows

✔ All checks have passed

  • Check website / html-check: successful
  • Merge button is enabled

✖ Some checks were not successful

  • Check website / html-check: failed
  • Click "Details" to read the log
  • Fix, push again; checks re-run automatically

What can beginners automate with GitHub Actions?

Useful automations for web builders

HTML and CSS checksCatch errors before merging
Broken link checksFind dead links on your site
TestsRun JavaScript or PHP tests on every PR
BuildCompile React, Vue or Tailwind sites
GitHub ActionsYour tireless robot assistant
DeployPublish to GitHub Pages or your hosting
Image optimisationCompress images automatically
Scheduled jobsWeekly checks or reports
Labels and welcomesGreet first-time contributors

How do I keep passwords safe in Actions?

Deployment often needs a password or token, for example to upload files to your hosting. Never write it in the workflow file. Instead, go to the repository's Settings, Secrets and variables, Actions, and add a repository secret, such as FTP_PASSWORD. Your workflow then refers to it by name using GitHub's secrets syntax, and GitHub hides secret values in logs. This is the same principle as the .env file from Part 10.

How much does GitHub Actions cost?

According to GitHub's pricing page, Actions is free for public repositories, and the Free plan includes 2,000 CI/CD minutes per month for private repositories. A small website check usually takes under a minute, so personal projects rarely come close to the limit. Check the pricing page for current details, as plans can change.

Actions on the Free plan

Freefor public repositories on standard runners
2,000minutes per month for private repositories
< 1 mintypical time for a simple HTML check

Source: GitHub pricing. Usage is shown under Settings, Billing.

What are common beginner mistakes with Actions?

Mistake and fix

Wrong folder

  • Workflows must be in .github/workflows/, with a dot before github

YAML indentation

  • Use spaces, never tabs; keep levels consistent

Secrets in files

  • Always use repository secrets

Ignoring red crosses

  • A failing check is information; read the log and fix it

Before Part 20, make sure you can

  • Explain workflow, event, job, step and runner
  • Create a workflow file in .github/workflows
  • Find and read a run in the Actions tab
  • See a check result on a pull request
  • Store a password as a repository secret

Her View

Automation can sound intimidating, but at heart it is about kindness to your future self and your team. Every check you automate is one less thing to remember on a busy day and one less chance of an embarrassing mistake on a client's live site. Start with one small workflow, see the green tick and enjoy the calm it brings.

Also readWhat Is Version Control? Git and GitHub for Beginners (Part 1)

His Insight

Begin with a single fast check on pull requests, then require it in branch protection. Add deployment only after checks are reliable. Keep workflows short and readable, pin actions to trusted versions, and store every credential as a secret. Measure success simply: fewer broken deployments and less time spent on manual checks.

H View Verdict

GitHub Actions turns your repository into a small automated factory: every push is checked, every pull request shows a clear result and deployments happen on their own. For beginners, one simple workflow already adds real safety. In the final part, Part 20, we bring everything together for the age of AI coding tools, with a complete cheat sheet.

Self-assessment: test yourself

Ready? Tap an option for each question. You will see right away whether you got it, with a short explanation, and your score at the end. Take your time, and try again as often as you like.

GitHub Actions quiz: 10 questions

1. Where do workflow files live?

  1. In the root folder
  2. In .github/workflows/
  3. In node_modules
  4. In the .git folder

GitHub looks for YAML workflow files in .github/workflows.

2. What starts a workflow?

  1. A runner
  2. An event such as push or pull_request
  3. A step
  4. A secret

Events trigger workflows.

3. Where should a deployment password go?

  1. In the YAML file
  2. In README.md
  3. In a repository secret
  4. In a commit message

Secrets keep credentials out of code and logs.

4. What does "runs-on: ubuntu-latest" choose?

  1. The branch
  2. The type of runner machine
  3. The programming language
  4. The reviewer

runs-on selects the operating system of the runner.

5. How many Actions minutes does the Free plan include for private repos each month?

  1. 100
  2. 500
  3. 2,000
  4. Unlimited

GitHub's pricing page lists 2,000 minutes a month on the Free plan; public repos are free.

6. What does CI stand for?

  1. Code Inspection
  2. Continuous integration
  3. Cloud Internet
  4. Commit Index

CI means checking every change automatically as it is pushed.

7. In the school analogy, the runner is

  1. The timetable
  2. The morning bell
  3. The classroom
  4. The headmaster

The runner is the machine where the work happens.

8. Which branch protection rule blocks merging until checks are green?

  1. Restrict deletions
  2. Require status checks to pass
  3. Block force pushes
  4. Require a README

It ensures failing checks stop the merge button.

9. What should you use for indentation in YAML?

  1. Tabs
  2. Spaces
  3. Commas
  4. Nothing

YAML requires spaces; tabs cause errors.

10. A check fails on your PR. What should you do?

  1. Merge anyway
  2. Read the log, fix the problem and push again
  3. Delete the workflow
  4. Close the PR

Checks re-run automatically after you push a fix.

Frequently asked questions

Do I need to know coding to use GitHub Actions?

Basic comfort with commands helps. Many workflows can be started from GitHub's templates in the Actions tab and adjusted slightly.

Can GitHub Actions deploy to my regular web hosting?

Yes. Actions from the Marketplace can upload files by FTP, SFTP or SSH to most hosting providers, using credentials stored as secrets.

What is YAML?

YAML is a simple text format for settings that uses indentation and "key: value" pairs. It is used by many tools, not just GitHub.

Is GitHub Actions the only CI/CD option?

No. GitLab CI, Bitbucket Pipelines and others offer similar features. If you use GitHub, Actions is the most convenient choice.

Part 19 of 20 in our Git and GitHub for Beginners series. A small tip from us: add the HTML check workflow to your portfolio repository today and enjoy your first green tick. Next up, the finale, Part 20: Git with AI coding tools, plus a complete cheat sheet.
Topics: Tech
Harika Behara

Writes for H View, where every story follows our editorial policy and is reviewed before it is published.

All stories by Harika →

H View stories follow our editorial policy. Spotted an error? Tell us and we will correct it.

Rate this article

One tap is enough. No comment needed.

Your rating
Be the first to rate it.

Was this article helpful?

Your answer goes straight to our editors.

Comments0

Be kind and stay on topic. Comments with links are checked before they appear.

No comments yet. Start the conversation.

The H View Brief

Our best stories, in your inbox.

The week’s best Her View, His Insight reading in one short, useful note.

Free. We only use your email to send The H View Brief. Unsubscribe any time.