ttvdrops/.github/workflows/deploy.yaml
Joakim Hellsén f6688ca904
All checks were successful
Deploy to Server / deploy (push) Successful in 13s
Fix conditional syntax for server health check in deploy workflow
2026-03-30 17:01:13 +02:00

46 lines
1.8 KiB
YAML

name: Deploy to Server
# EDITOR=nvim visudo
# forgejo-runner ALL=(ttvdrops) NOPASSWD: /usr/bin/git
# forgejo-runner ALL=(root) NOPASSWD: /bin/systemctl restart ttvdrops
# forgejo-runner ALL=(ttvdrops) NOPASSWD: /usr/bin/uv run python /home/ttvdrops/ttvdrops/manage.py migrate
# forgejo-runner ALL=(ttvdrops) NOPASSWD: /usr/bin/uv sync -U --all-extras --dev --directory /home/ttvdrops/ttvdrops
# forgejo-runner ALL=(ttvdrops) NOPASSWD: /usr/bin/uv run python /home/ttvdrops/ttvdrops/manage.py collectstatic --noinput
on:
push:
pull_request:
workflow_dispatch:
jobs:
deploy:
runs-on: self-hosted
env:
DJANGO_DEBUG: False
DJANGO_SECRET_KEY: 1234567890
steps:
- uses: actions/checkout@v6
- run: uv sync --all-extras --dev -U
- run: uv run pytest
- name: Check if makemigrations are needed
run: |
if uv run python manage.py makemigrations --check --dry-run; then
echo "No migrations needed."
else
echo "Migrations needed. Please create and commit migrations before deploying."
exit 1
fi
- name: Deploy to Server
if: ${{ success() && github.ref == 'refs/heads/master' }}
run: |
sudo -u ttvdrops git -C /home/ttvdrops/ttvdrops pull
sudo -u ttvdrops uv sync -U --all-extras --dev --directory /home/ttvdrops/ttvdrops
sudo -u ttvdrops uv run python /home/ttvdrops/ttvdrops/manage.py migrate
sudo -u ttvdrops uv run python /home/ttvdrops/ttvdrops/manage.py collectstatic --noinput
sudo systemctl restart ttvdrops
- name: Check if server is up
if : ${{ success() && github.ref == 'refs/heads/master' }}
run: |
sleep 2
curl -f https://ttvdrops.lovinator.space/ || exit 1