Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/preview-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Preview Deploy
on:
workflow_dispatch:
inputs:
ref:
description: 'The git ref to deploy (branch, tag, or SHA)'
required: true
default: 'main'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PREVIEW_HOST }}
username: ${{ secrets.PREVIEW_USER }}
key: ${{ secrets.PREVIEW_SSH_KEY }}
port: ${{ secrets.PREVIEW_SSH_PORT || 22 }}
script: |
cd ${{ secrets.PREVIEW_PROJECT_DIR }}
./scripts/deploy-preview.sh ${{ github.event.inputs.ref }}
15 changes: 15 additions & 0 deletions scripts/deploy-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
REF="${1:-main}"

echo "Deploying ref: $REF"
git fetch origin
git checkout "$REF"
git pull origin "$REF"

# Standard Django deployment steps
pip install -r requirements.txt
python manage.py migrate --noinput
python manage.py collectstatic --noinput
# Restarting services (this may vary by server config)
sudo systemctl restart gunicorn