This commit is contained in:
45
.gitea/workflows/deploy.yml
Normal file
45
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Deploy bot
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# ---- Build Docker image ----
|
||||
- name: Build image
|
||||
run: |
|
||||
docker build -t trilium-bot:latest .
|
||||
|
||||
# ---- Tag & push to local registry ----
|
||||
- name: Tag image
|
||||
run: |
|
||||
docker tag trilium-bot:latest 192.168.1.20:5000/trilium-bot:latest
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
docker push 192.168.1.20:5000/trilium-bot:latest
|
||||
# ---- Deploy to server ----
|
||||
- name: Deploy over SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
printf "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config
|
||||
|
||||
ssh $SERVER_USER@$SERVER_HOST "
|
||||
docker pull 192.168.1.20:5000/trilium-bot:latest &&
|
||||
cd /srv/trilium-bot &&
|
||||
docker compose down || true &&
|
||||
docker compose up -d
|
||||
"
|
||||
env:
|
||||
SERVER_HOST: ${{ secrets.SERVER_HOST }}
|
||||
SERVER_USER: ${{ secrets.SERVER_USER }}
|
||||
SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
Reference in New Issue
Block a user