Skip to content

Commit 1135a04

Browse files
committed
Add staging workflow file
1 parent 0e7cd20 commit 1135a04

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/django.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Django CI
2+
3+
on:
4+
push:
5+
branches: [ "main", "staging" ]
6+
pull_request:
7+
branches: [ "main", "staging" ]
8+
9+
jobs:
10+
build:
11+
environment: ${{ github.ref_name }}
12+
name: "Deploy to ${{ github.ref_name }}"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Configure SSH
16+
env:
17+
SSH_USER: ${{ secrets.SSH_USER }}
18+
SSH_KEY: ${{ secrets.SSH_KEY }}
19+
SSH_HOST: ${{ secrets.SSH_HOST }}
20+
run: |
21+
mkdir -p ~/.ssh/
22+
echo "$SSH_KEY" > ~/.ssh/server.key
23+
chmod 600 ~/.ssh/server.key
24+
cat >>~/.ssh/config <<END
25+
Host server
26+
HostName $SSH_HOST
27+
User $SSH_USER
28+
IdentityFile ~/.ssh/server.key
29+
StrictHostKeyChecking no
30+
END
31+
- name: Deploy to Server
32+
env:
33+
ROOT_DIR: ${{ vars.ROOT_DIR }}
34+
ENV_DIR: ${{ vars.ENV_DIR }}
35+
run: |
36+
ssh server "
37+
cd $ROOT_DIR &&
38+
git pull origin main &&
39+
source $ENV_DIR &&
40+
pip install -r requirements/production.txt &&
41+
python manage.py migrate --settings=config.settings.production &&
42+
python manage.py collectstatic --noinput --settings=config.settings.production &&
43+
supervisorctl restart django
44+
"

0 commit comments

Comments
 (0)