-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (62 loc) · 1.92 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
71
72
73
74
75
76
77
78
name: CI
on:
push:
branches: [ "*" ]
pull_request:
branches: [ master ]
jobs:
build_app:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Check PEP8
run: |
python -m flake8
- name: Run tests
env:
OC_LETTING_SK: ${{ secrets.OC_LETTING_SK }}
DJANGO_DEBUG: 1
run: pytest --cov-config=setup.cfg --cov=. --cov-fail-under=80
build_docker:
needs: build_app
runs-on: ubuntu-latest
if: github.event.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
# build and push the image tagged with commit hash
docker build \
--push \
--tag tmenanteau/oc_lettings:${{ github.sha }} \
--build-arg OC_LETTING_SENTRY_KEY="${{ secrets.OC_LETTING_SENTRY_KEY }}" \
--build-arg OC_LETTING_SK="${{ secrets.OC_LETTING_SK }}" \
.
# tag the image as the latest version
docker tag tmenanteau/oc_lettings:${{ github.sha }} tmenanteau/oc_lettings:latest
docker push tmenanteau/oc_lettings:latest
deploy:
needs: build_docker
runs-on: ubuntu-latest
if: github.event.ref == 'refs/heads/master'
steps:
- name: deploy
run: |
curl "${{ secrets.RENDER_DEPLOY_HOOK_URL }}"