Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/model-training.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Python und install requirements
uses: actions/setup-python@v4
with:
python-version: "3.8"
- run: pip install -r requirements.txt

- name: Train model
run: python src/train.py

- name: Upload trained model
uses: actions/upload-artifact@v4
with:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/production-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy to Production
on:
push:
branches:
- main

jobs:
train-model:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Switch to heroku branch
shell: bash
run: |
git config --global user.email ""
git config --global user.name "Github Actions"
git fetch --all --unshallow
git checkout heroku 2>/dev/null || git checkout -b heroku
git merge main -X theirs --allow-unrelated-histories

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Install dependencies
run: pip install -r requirements.txt

- name: Train model
run: python src/train.py

- name: Upload trained model
uses: actions/upload-artifact@v4
with:
name: regressor_mpg.pickle
path: data/models/regressor_mpg.pickle

- name: Push changes to heroku branch
shell: bash
run: |
git add .
git add --force data/models/regressor_mpg.pickle
git commit -m "[CI] update trained model" || echo "No changes to commit"
git push --set-upstream origin heroku

- name: Deploy to Heroku
uses: akhileshns/heroku-deploy@v3.13.15
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
heroku_email: ${{secrets.HEROKU_EMAIL}}
branch: "heroku"
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn src.api:app