ci(gitea): add Gitea Actions deployment workflow and Gitea CI/CD guide
Some checks failed
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Has been cancelled
Some checks failed
Deploy RIT Freshers Hub to VPS / Deploy to Live VPS (push) Has been cancelled
This commit is contained in:
42
.gitea/workflows/deploy.yml
Normal file
42
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
name: Deploy RIT Freshers Hub to VPS
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
name: Deploy to Live VPS
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: SSH into VPS and Deploy
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.VPS_HOST }}
|
||||||
|
username: ${{ secrets.VPS_USERNAME }}
|
||||||
|
key: ${{ secrets.VPS_SSH_KEY }}
|
||||||
|
port: 22
|
||||||
|
script: |
|
||||||
|
echo "🚀 Starting Automated CI/CD Deployment from Gitea..."
|
||||||
|
cd /var/www/freshers-hub
|
||||||
|
|
||||||
|
echo "📥 Pulling latest code from Gitea..."
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
echo "⚡ Building Frontend PWA..."
|
||||||
|
npm install --production=false
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
echo "🤖 Building Go Chatbot..."
|
||||||
|
cd /var/www/freshers-hub/chatbot-service
|
||||||
|
go build -o chatbot-service main.go
|
||||||
|
|
||||||
|
echo "🔄 Restarting Systemd Services..."
|
||||||
|
systemctl restart springboot chatbot telegram-bot nginx
|
||||||
|
|
||||||
|
echo "🎉 Deployment Completed Successfully!"
|
||||||
62
GITEA_CICD_GUIDE.md
Normal file
62
GITEA_CICD_GUIDE.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# 🦊 RIT Freshers Hub - Gitea CI/CD Pipeline Guide
|
||||||
|
|
||||||
|
Automate your deployments from your self-hosted Gitea repository (`https://git.rit-services.in/ShanmugaKrishnanSM/RIT-nexus.git`) directly to your live VPS!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛠️ Choose Your Preferred Gitea CI/CD Method:
|
||||||
|
|
||||||
|
* **Method 1: Gitea Actions (Recommended if Gitea Actions is enabled)** — Uses `.gitea/workflows/deploy.yml` with identical syntax to GitHub Actions.
|
||||||
|
* **Method 2: Gitea Webhook + Lightweight VPS Script (Fastest & Zero Setup)** — Gitea sends an HTTP trigger on push to automatically execute `git pull && npm run build` on your VPS.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Method 1: Setting Up Gitea Actions
|
||||||
|
|
||||||
|
### Step 1: Add Secrets in Gitea
|
||||||
|
1. Open your repository in Gitea:
|
||||||
|
`https://git.rit-services.in/ShanmugaKrishnanSM/RIT-nexus`
|
||||||
|
2. Click **Settings** (top right) ➔ **Actions** ➔ **Secrets**.
|
||||||
|
3. Add these 3 secrets:
|
||||||
|
* **`VPS_HOST`**: `129.121.126.66`
|
||||||
|
* **`VPS_USERNAME`**: `root`
|
||||||
|
* **`VPS_SSH_KEY`**: Paste your SSH Private Key (`cat ~/.ssh/id_rsa` from VPS).
|
||||||
|
|
||||||
|
### Step 2: Push Workflow File
|
||||||
|
The Gitea workflow file is located at [.gitea/workflows/deploy.yml](file:///f:/fresher/Freshers-Hub/.gitea/workflows/deploy.yml).
|
||||||
|
|
||||||
|
Every `git push origin main` will automatically run the deployment steps on your VPS!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚡ Method 2: Setting Up Gitea Webhook (Lightweight & Instant)
|
||||||
|
|
||||||
|
If Gitea Actions runner is not active on your Gitea instance, you can use a native **Gitea Webhook**:
|
||||||
|
|
||||||
|
### Step 1: Create a Deploy Script on VPS
|
||||||
|
On your VPS terminal (`ssh root@129.121.126.66`), create a deployment shell script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat << 'EOF' > /var/www/freshers-hub/deploy.sh
|
||||||
|
#!/bin/bash
|
||||||
|
echo "🚀 Deploying latest code from Gitea..."
|
||||||
|
cd /var/www/freshers-hub
|
||||||
|
git pull origin main
|
||||||
|
npm run build
|
||||||
|
cd chatbot-service && go build -o chatbot-service main.go
|
||||||
|
systemctl restart springboot chatbot telegram-bot nginx
|
||||||
|
echo "✅ Deployment finished!"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x /var/www/freshers-hub/deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: Add Webhook in Gitea
|
||||||
|
1. Go to your Gitea Repo ➔ **Settings** ➔ **Webhooks**.
|
||||||
|
2. Click **Add Webhook** ➔ Select **Gitea**.
|
||||||
|
3. **Target URL:** `http://129.121.126.66:9000/hooks/deploy` (or your webhook port).
|
||||||
|
4. **HTTP Method:** `POST`
|
||||||
|
5. **Trigger On:** Push Events.
|
||||||
|
6. Click **Add Webhook**.
|
||||||
|
|
||||||
|
Whenever you push code to Gitea, it triggers `deploy.sh` on your VPS instantly!
|
||||||
Reference in New Issue
Block a user