Upgraded Versions #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main Workflow - Test and Deploy | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }} | |
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }} | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
jobs: | |
health-checkup-job: #Check the healthy by running tests | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run Tests | |
run: | | |
python manage.py test | |
- name: Check Syntax | |
run: black . --check -l 120 | |
deployment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Heroku login credentials | |
run: | | |
cat > ~/.netrc <<EOF | |
machine api.heroku.com | |
login $HEROKU_EMAIL | |
password $HEROKU_API_KEY | |
machine git.heroku.com | |
login $HEROKU_EMAIL | |
password $HEROKU_API_KEY | |
EOF | |
env: | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }} | |
- name: Add Heroku remote | |
run: heroku git:remote --app $HEROKU_APP_NAME | |
env: | |
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }} | |
- name: Push to Heroku | |
run: git push heroku main |