Deploy a Website to the Cloud with GitHub Actions

root

Jun 11 2026


What You'll Build

A workflow that automatically deploys your website to GitHub Pages every time you push code.

Prerequisites

Step 1 — Create a Simple Website

In your repo, create index.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>My Deployed Site</title>
</head>
<body>
  <h1>🚀 Deployed automatically with GitHub Actions!</h1>
  <p>Every push to main triggers a new deploy.</p>
</body>
</html>

Step 2 — Create the GitHub Actions Workflow

In your repo, create the folder path .github/workflows/ and inside it a file called deploy.yml:

name: Deploy to GitHub Pages

# Trigger: run this workflow on every push to the main branch
on:
  push:
    branches:
      - main

# Grant permission to write to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      # Step 1: Check out the repository code
      - name: Checkout code
        uses: actions/checkout@v4

      # Step 2: Upload the site files as an artifact
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: "."   # Deploy everything in the root folder

      # Step 3: Deploy to GitHub Pages
      - name: Deploy to GitHub Pages
        uses: actions/deploy-pages@v4

Step 3 — Enable GitHub Pages

  1. Go to your repo → SettingsPages
  2. Under Source, select GitHub Actions
  3. Save the settings

Step 4 — Push and Watch It Deploy

git add .
git commit -m "Add CI/CD workflow"
git push origin main

Go to the Actions tab in your GitHub repo and watch the pipeline run live. Once it finishes (usually under 1 minute), your site is live at:

https://<your-username>.github.io/<your-repo-name>/

Well done!

You have a fully automated deployment pipeline. Every future git push will automatically update your live site.


root

Just share your knowledge!