-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 1.97 KB
/
django-ci.yml
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
name: Django CI Pipeline
on:
push:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
DJANGO_DEBUG: "True"
DJANGO_SECURE_SSL_REDIRECT: "False"
DJANGO_SECURE_HSTS_SECONDS: 0
DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS: "False"
DJANGO_SECURE_HSTS_PRELOAD: "False"
DJANGO_SESSION_COOKIE_SECURE: "False"
DJANGO_CSRF_COOKIE_SECURE: "False"
MDB_PRO_KEY: ${{ secrets.MDB_PRO_KEY }}
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: user/app:latest
- name: Start Docker Compose services
run: docker-compose up -d
- name: Run backend tests
run: docker-compose exec web pytest
- name: Add MDB API Key
run: docker-compose exec web python manage.py addapikey
- name: Run frontend tests
run: |
docker-compose exec web bash -c "cd frontend && npm install && npm run test"
- name: Remove MDB API Key
run: docker-compose exec web python manage.py removeapikey
- name: Clean up
run: docker-compose down