-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (111 loc) · 4.31 KB
/
ci.yml
File metadata and controls
126 lines (111 loc) · 4.31 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: CI pipeline
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
security-job:
runs-on: ubuntu-latest
if: | # security runs either on main or PR
github.event_name == 'push' && contains(fromJson('["refs/heads/master", "refs/heads/main"]'), github.ref) ||
(github.event_name == 'pull_request')
steps:
- name: Check out repository code
uses: actions/checkout@v4
- uses: microsoft/DevSkim-Action@v1
with:
output-filename: devskim-results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: devskim-results.sarif
category: DevSkim
test-job:
if: | # I don't want to run on dependebot pushes, just pr, but for the rest all, including all prs
(github.event_name == 'push' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request')
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [ "3.11" ]
container: python:${{ matrix.python-version }}-bookworm
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:15
# Provide the password for postgres
env:
POSTGRES_DB: django_db
POSTGRES_USER: django_user
POSTGRES_PASSWORD: django_pass
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- run: echo "Starting build"
- run: apt update && apt install -y gcc libpq-dev libz-dev
- name: Check out repository code
uses: actions/checkout@v4
- name: Install Poetry
run: |
curl -fsS -o get-poetry.py https://install.python-poetry.org
python get-poetry.py -y
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --no-interaction
- name: Run tests
run: poetry run python manage.py test -v 3
env:
DJANGO_SETTINGS_MODULE: "contrast_api.settings"
DJANGO_CONFIGURATION: "Testing"
DATABASE_URL: "postgresql://django_user:django_pass@postgres/django_db"
deploy:
if: contains(fromJson('["refs/heads/master", "refs/heads/main"]'), github.ref)
needs: [test-job, security-job]
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v4
# - name: Install Poetry
# run: |
# curl -fsS -o get-poetry.py https://install.python-poetry.org
# python get-poetry.py -y
# echo "$HOME/.local/bin" >> $GITHUB_PATH
# - name: export to requirements.txt
# run: poetry self add poetry-plugin-export && poetry export --without-hashes -f requirements.txt --output requirements.txt
- name: Check out repository frontend repository
uses: actions/checkout@v4
with:
repository: "Mudrik-Lab/ContrastFront"
ssh-key: ${{ secrets.CONTRAST_DEPLOY_KEY }}
path: ContrastFront
- name: build front app
uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci
working-directory: ./ContrastFront
- run: npm run build:contrast
working-directory: ./ContrastFront
- run: npm run build:uncontrast
working-directory: ./ContrastFront
- name: adding front code to django - contrast
run: cp -r ./ContrastFront/dist-contrast/* frontapp/contrast
- name: adding front code to django - uncontrast front
run: cp -r ./ContrastFront/dist-uncontrast/* frontapp/uncontrast
- name: Deploying to heroku
if: contains(fromJson('["refs/heads/master", "refs/heads/main"]'), github.ref)
uses: akhileshns/heroku-deploy@v3.13.15
with:
heroku_email: ${{secrets.HEROKU_USER_EMAIL}}
# https://help.heroku.com/PBGP6IDE/how-should-i-generate-an-api-key-that-allows-me-to-use-the-heroku-platform-api
# Note this yochai token, if it's revoked follow the link above to generate a new token, update in repo settings and replace the email accordingly
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "contrast2-api"