# Assignment 1 — DevOps CI/CD Website ```html
Azure VM Hosting using GitHub Actions CI/CD
This project demonstrates how to host a static website on an Azure Virtual Machine using Nginx and automate deployment using GitHub Actions.
Connected to Azure Ubuntu VM using SSH.
ssh raif@20.66.70.155
Installed Nginx and Git on the Azure VM.
sudo apt update
sudo apt install nginx git -y
Created website folder and added HTML code.
mkdir ~/mywebsite
cd ~/mywebsite
nano index.html
Created GitHub repository and pushed local code using Git.
git init
git add .
git commit -m "Initial website"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/mywebsite.git
git push -u origin main
Configured Nginx to serve website files.
sudo nano /etc/nginx/sites-available/mywebsite
sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Configured GitHub Actions workflow to automatically deploy changes to Azure VM.
name: Deploy Website
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to Azure VM
uses: appleboy/ssh-action@v1.0.3
Fixed SSH authentication issue by generating SSH keys for the correct user (raif) and adding the public key to authorized_keys.
ssh-keygen -t rsa -b 4096
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Fixed Git safe directory and ownership issues.
sudo chown -R raif:raif /home/raif/mywebsite
sudo chown -R raif:raif /var/www/mywebsite
git config --global --add safe.directory /home/raif/mywebsite
git config --global --add safe.directory /var/www/mywebsite
Created a free DuckDNS domain and pointed it to the Azure VM public IP.
Domain Created:
raif-assigment1.duckdns.org
Azure VM Public IP:
20.66.70.155
Installed Certbot and generated a free SSL certificate using Let's Encrypt.
sudo apt update
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx
Certbot automatically configured HTTPS and SSL certificates for the website.
The website is now securely accessible using HTTPS with automatic certificate renewal.
https://raif-assigment1.duckdns.org
The website is now automatically deployed whenever code is pushed to GitHub.
Technologies Used: