Skip to content

Commit

Permalink
Create django.yml workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
bruecksen authored May 31, 2024
1 parent efa0364 commit 787ddaa
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Django CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.9, 3.10]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py test
- name: Deploy to Server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
run: |
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
ssh $SSH_USERNAME@$SSH_HOST '
cd /home/django/bakeup/ &&
git pull origin main &&
source /home/django/djangoenv/bin/activate &&
pip install -r requirements.txt &&
python manage.py migrate &&
python collectstatic --noinput &&
supervisorctl restart django
'

0 comments on commit 787ddaa

Please sign in to comment.