name: Deploy bot on: push: branches: [ main ] jobs: build-deploy: runs-on: ubuntu-latest 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/docker/compose && docker compose -f trilium_bot.yml down || true && docker compose -f trilium_bot.yml up -d " env: SERVER_HOST: ${{ secrets.SERVER_HOST }} SERVER_USER: ${{ secrets.SERVER_USER }} SSH_KEY: ${{ secrets.SSH_KEY }}