ttvdrops/.github/workflows/deploy.yaml
Joakim Helleśen b57e5daae4
All checks were successful
Deploy to Server / deploy (push) Successful in 13s
Update deployment workflow to include additional parameters for uv sync command
2026-03-17 22:01:08 +01:00

44 lines
1.5 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
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 systemctl restart ttvdrops
- name: Check if server is up
run: |
sleep 2
curl -f https://ttvdrops.lovinator.space/ || exit 1