Skip to content

Commit 6e44399

Browse files
Add heroku setup and action
1 parent 464716c commit 6e44399

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/model-training.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ jobs:
66
steps:
77
- name: Checkout Repository
88
uses: actions/checkout@v3
9+
910
- name: Setup Python und install requirements
1011
uses: actions/setup-python@v4
1112
with:
1213
python-version: "3.8"
1314
- run: pip install -r requirements.txt
15+
1416
- name: Train model
1517
run: python src/train.py
18+
1619
- name: Upload trained model
1720
uses: actions/upload-artifact@v4
1821
with:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy to Production
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
train-model:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Switch to heroku branch
13+
shell: bash
14+
run: |
15+
git config --global user.email ""
16+
git config --global user.name "Github Actions"
17+
git fetch --all --unshallow
18+
git checkout heroku 2>/dev/null || git checkout -b heroku
19+
git merge main -X theirs --allow-unrelated-histories
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: "3.9"
25+
26+
- name: Install dependencies
27+
run: pip install -r requirements.txt
28+
29+
- name: Train model
30+
run: python src/train.py
31+
32+
- name: Upload trained model
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: regressor_mpg.pickle
36+
path: data/models/regressor_mpg.pickle
37+
38+
- name: Push changes to heroku branch
39+
shell: bash
40+
run: |
41+
git add .
42+
git add --force data/models/regressor_mpg.pickle
43+
git commit -m "[CI] update trained model" || echo "No changes to commit"
44+
git push --set-upstream origin heroku
45+
46+
- name: Deploy to Heroku
47+
uses: akhileshns/heroku-deploy@v3.13.15
48+
with:
49+
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
50+
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
51+
heroku_email: ${{secrets.HEROKU_EMAIL}}
52+
branch: "heroku"

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn src.api:app

0 commit comments

Comments
 (0)