62 lines
1.4 KiB
Markdown
62 lines
1.4 KiB
Markdown
# Deploy
|
|
|
|
Auto-deploy snotes when code is pushed to Gitea.
|
|
|
|
## How it works
|
|
|
|
```
|
|
User pushes → Gitea webhook POST → webhook-server.py → git pull
|
|
→ docker compose build
|
|
→ docker compose up -d
|
|
→ health check
|
|
```
|
|
|
|
The webhook server runs on the Docker host (ppv.loc) and listens for push events
|
|
from Gitea.
|
|
|
|
## Setup
|
|
|
|
### 1. Start the webhook server on the Docker host
|
|
|
|
```bash
|
|
cd /root/git/snotes/deploy
|
|
python3 webhook-server.py --port 9997 --secret "<your-secret>"
|
|
```
|
|
|
|
Or run as a systemd service (see below).
|
|
|
|
### 2. Configure Gitea webhook
|
|
|
|
In the Gitea repo **Settings > Webhooks > Add Webhook > Gitea**:
|
|
|
|
- **Target URL**: `http://ppv.loc:9997/deploy`
|
|
- **Secret**: same `<your-secret>` from step 1
|
|
- **Trigger On**: Push events
|
|
- **Active**: ✅
|
|
|
|
### 3. Test
|
|
|
|
Push to `main`. The webhook server logs each step.
|
|
|
|
## systemd service (recommended)
|
|
|
|
Install `deploy/snotes-deploy.service`:
|
|
|
|
```bash
|
|
cp deploy/snotes-deploy.service /etc/systemd/system/snotes-deploy.service
|
|
# edit the --secret value in the unit, then:
|
|
systemctl daemon-reload
|
|
systemctl enable --now snotes-deploy
|
|
```
|
|
|
|
## Manual deploy
|
|
|
|
```bash
|
|
bash deploy/deploy.sh
|
|
```
|
|
|
|
## Secrets / config
|
|
|
|
`deploy/deploy.conf` (gitignored) can carry a `GIT_TOKEN` for HTTP remotes. The
|
|
default checkout uses SSH, so no token is needed.
|