Files
grateful-journal/CICD_SETUP.md
2026-04-08 11:19:01 +05:30

2.3 KiB

CI/CD Setup — Gitea Actions (Auto Deploy)

This doc covers how to set up automatic deployment to your VPS whenever you push to main. The deploy runs deploy.sh (git pull && docker-compose down && docker-compose up -d --build).

The runner is installed directly on the VPS — no SSH keys needed.


Step 1 — Install act_runner on your VPS

wget https://gitea.com/gitea/act_runner/releases/latest/download/act_runner-linux-amd64
chmod +x act_runner-linux-amd64
mv act_runner-linux-amd64 /usr/local/bin/act_runner

Step 2 — Get a runner token from Gitea

Go to: Gitea repo → Settings → Actions → Runners → Create Runner

Copy the token shown.


Step 3 — Register the runner on your VPS

act_runner register \
  --instance https://YOUR_GITEA_URL \
  --token YOUR_RUNNER_TOKEN \
  --name vps-runner \
  --labels ubuntu-latest

Step 4 — Run it as a systemd service

nano /etc/systemd/system/act_runner.service

Paste:

[Unit]
Description=Gitea Act Runner
After=network.target

[Service]
ExecStart=/usr/local/bin/act_runner daemon
WorkingDirectory=/root
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start:

systemctl daemon-reload
systemctl enable --now act_runner

Step 5 — Create the workflow file

File is already at .gitea/workflows/deploy.yml:

name: Deploy to VPS

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy
        run: |
          cd /path/to/grateful-journal
          bash deploy.sh

Update /path/to/grateful-journal to the actual path on your VPS where the repo is cloned.


Step 6 — Make sure the repo is cloned on your VPS

git clone https://YOUR_GITEA_URL/username/grateful-journal.git

Skip if already cloned.


How it works

Push to main
  → Gitea triggers the workflow
  → act_runner (on VPS) picks up the job
  → Runs deploy.sh in place: git pull + docker-compose rebuild
  → App is live

Verifying it works

  1. Push a commit to main
  2. Go to Gitea repo → Actions tab
  3. You should see the workflow run with step-by-step logs

If the runner isn't picking up jobs, check it's online at Site Administration → Runners.