Files
Botinator/.gitea/workflows/ci-cd.yaml
T
ksan d4062f98a3
CI/CD / build (push) Successful in 44s
CI/CD / deploy (push) Failing after 27s
fixed path
2026-07-10 00:47:23 +02:00

60 lines
1.9 KiB
YAML

name: CI/CD
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
- name: Build
run: |
chmod +x gradlew
./gradlew --no-daemon build
deploy:
runs-on: ubuntu-latest
needs: build
if: gitea.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Build & push Docker image
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login git.${{ secrets.DOMAIN }} \
-u ${{ secrets.REGISTRY_USER }} --password-stdin
docker build -t git.${{ secrets.DOMAIN }}/${{ secrets.REGISTRY_USER }}/botinator:latest .
docker push git.${{ secrets.DOMAIN }}/${{ secrets.REGISTRY_USER }}/botinator:latest
- name: Deploy to VPS
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/key
chmod 600 ~/.ssh/key
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
HOST=${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}
# Path relative to the remote user's home (ssh/scp start there). Do NOT
# use ~ here — it would expand on the runner, not on the server.
DIR=programs/botinator
# Ship the compose file and Lavalink config to the server. .env and
# catchphrases.txt live on the server and are intentionally not copied.
ssh -i ~/.ssh/key $HOST "mkdir -p $DIR/lavalink"
scp -i ~/.ssh/key docker-compose.yaml $HOST:"$DIR/docker-compose.yaml"
scp -i ~/.ssh/key lavalink/application.yml $HOST:"$DIR/lavalink/application.yml"
ssh -i ~/.ssh/key $HOST \
"cd $DIR && docker compose pull && docker compose up -d"