-
Notifications
You must be signed in to change notification settings - Fork 25
91 lines (88 loc) · 3.13 KB
/
build-deploy-model.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
79
80
81
82
83
84
85
86
87
88
89
90
91
# Your workflow name.
name: test-build-model-app
# Run workflow on every push to master branch.
on:
repository_dispatch:
types: [on-demand-run]
push:
paths:
- 'model/**'
- 'shared/**'
- 'database/model/migrations/**'
- '.github/workflows/build-deploy-model.yml'
env:
DIRECTORY: model
HEROKU_WEB_PROCESS: web
HEROKU_WORKER_PROCESS: worker
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_APP_NAME: ${{ secrets.HEROKU_MODEL_APP_NAME }}
EXECUTION_APP_URL: https://${{ secrets.HEROKU_EXECUTION_APP_NAME }}.herokuapp.com
SECRET_KEY: ${{ secrets.SECRET_KEY}}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install and configure Poetry
uses: snok/install-poetry@v1.3.3
with:
version: 1.4.2
virtualenvs-create: false
- name: Install dependencies
run: |
cd $DIRECTORY/
poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi
- name: Test with pytest
env:
TEST: true
run: |
python -m pytest $DIRECTORY/ --ds=database.settings --verbose --cov=model/strategies \
--cov=model/service --cov=model/backtesting --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
test-build:
runs-on: ubuntu-latest
needs: test
if: github.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Build web Docker image
run: docker build -f $DIRECTORY/Dockerfile.$HEROKU_WEB_PROCESS -t $DIRECTORY-$HEROKU_WEB_PROCESS-app .
- name: Build worker Docker image
run: docker build -f $DIRECTORY/Dockerfile.$HEROKU_WORKER_PROCESS -t $DIRECTORY-$HEROKU_WORKER_PROCESS-app .
build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Login to heroku container registry
run: |
echo ${{ secrets.HEROKU_API_KEY }} | docker login --username=${{ secrets.HEROKU_EMAIL }} registry.heroku.com --password-stdin
- name: Build and push
run: |
cd $DIRECTORY/
heroku container:push --recursive --app $HEROKU_APP_NAME --context-path=../ --arg APP_NAME=$HEROKU_APP_NAME,\
EXECUTION_APP_URL=$EXECUTION_APP_URL,SECRET_KEY=$SECRET_KEY
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Login to heroku container registry
run: |
echo ${{ secrets.HEROKU_API_KEY }} | docker login --username=${{ secrets.HEROKU_EMAIL }} registry.heroku.com --password-stdin
- name: Deploy
run: heroku container:release $HEROKU_WEB_PROCESS $HEROKU_WORKER_PROCESS --app $HEROKU_APP_NAME