-
Notifications
You must be signed in to change notification settings - Fork 9
107 lines (90 loc) · 2.75 KB
/
django-test-deploy-master.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Django Test Deploy Master
on:
push:
branches:
- master
schedule:
- cron: "0 3 * * 0-6" # Every day at 3am UTC
env:
DEBUG: False
LOGGING: False
DJANGO_SETTINGS_MODULE: django_project.settings.ci
USE_SQLITE: True
SECRET_KEY: "Not applicable for tests"
ALLOWED_HOSTS: "127.0.0.1 localhost"
SITE_ID: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: update-system-dependencies
run: |
sudo apt-get update -y
- name: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.10.8
cache: "pip"
- name: install-python-virtualenv
run: |
python3 -m venv venv django_project/venv
source django_project/venv/bin/activate
pip install --upgrade pip
pip install wheel
pip install -r django_project/requirements/requirements.txt
- name: lint-with-ruff
run: |
source django_project/venv/bin/activate
ruff --config ./config/pyproject.toml django_project
- name: collect-static-files
run: |
source django_project/venv/bin/activate
python3 django_project/manage.py collectstatic --noinput
- name: run-db-migrations
run: |
source django_project/venv/bin/activate
python3 django_project/manage.py migrate --noinput
- name: run-unit-tests-with-coverage
run: |
source django_project/venv/bin/activate
coverage run --rcfile=config/.coveragerc -m pytest django_project
coverage lcov --rcfile=config/.coveragerc
- name: coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
static_analysis:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["javascript", "python"]
steps:
- uses: actions/checkout@v3
- name: initialize-codeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: perform-codeQL Analysis
uses: github/codeql-action/analyze@v2
deploy:
needs: [build, static_analysis]
runs-on: ubuntu-latest
steps:
- name: deploy-to-linode
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd blogthedata
git pull
source django_project/venv/bin/activate
python3 django_project/manage.py collectstatic --noinput
sudo systemctl restart gunicorn