Deploying a static website manually can be tedious, especially when youβre updating it frequently. Thatβs why I decided to automate my deployment process using GitHub Actionsβa powerful CI/CD tool built right into GitHub.
In this post, Iβll walk you through how I deployed my static website automatically to an NGINX server using GitHub Actions.
π οΈ Tools I Used
- GitHub β to store my websiteβs source code
- GitHub Actions β to automate the deployment
- Ubuntu Server with NGINX β to host the static site
- Self-Hosted GitHub Runner β on the Ubuntu server
π Project Structure
My website files are stored in this directory:
_work/ci-static-simple-website/ci-static-simple-website/
β
βββ index.html
βββ README.md
βοΈ Setting Up the GitHub Action
I created a .github/workflows/deploy.yml file in my repo to define the deployment pipeline.
Hereβs a simple version of my GitHub Actions workflow:
name: Deploy Static Website
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Copy index.html to NGINX Web Directory
run: |
cp _work/ci-static-simple-website/ci-static-simple-website/index.html /var/www/html/index.html
sudo systemctl reload nginx
After successfully testing my code.
Deploying my code to the Linux self-hosted server in process.
π How It Works
- Every time I push to the
mainbranch, the GitHub Action is triggered. - The self-hosted runner on my Ubuntu server picks it up.
- It copies the
index.htmlfile into/var/www/html/. - It reloads NGINX to apply changes immediately.
Successful deployed and it running fine.
My Code is running Live.
π Final Result
Once the action runs, my static website is instantly live at my serverβs public IP!
π‘ Why This Is Awesome
- I never have to manually copy files again
- It works perfectly for personal portfolios, landing pages, or project demos
- Super fast and reliable!
Let me know in the comments if you'd like a step-by-step guide to setting up your own self-hosted runner or customizing your deployment pipeline!





Top comments (0)