-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (66 loc) · 1.82 KB
/
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
70
on:
push:
branches:
- main
pull_request:
name: CI
jobs:
test:
runs-on: ubuntu-latest
name: Test
env:
DJANGO_DEBUG: 'True'
PORT: '8000'
DATABASE_URL: 'postgres://pg:passw0rd@localhost/reservation-api'
services:
postgres:
image: postgres:13.2-alpine
env:
POSTGRES_USER: pg
POSTGRES_PASSWORD: passw0rd
POSTGRES_DB: reservation-api
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run migrations
run: ./manage.py migrate
- name: Collect static files
run: ./manage.py collectstatic --noinput
- name: Install dev dependencies
run: |
pip install -r requirements-dev.txt
- name: Run pytest
run: pytest
docker_image:
name: Build Docker image
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: |
docker build \
--no-cache \
-t coredump/reservation-api:main \
-t coredump/reservation-api:latest \
.
- name: Push Docker image (only on main)
if: github.ref == 'refs/heads/main'
run: |
docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}" && \
docker push -a coredump/reservation-api