| name: Django CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - run: | | |
| git fetch --unshallow origin | |
| - name: Set up Python 3.8 | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: 3.8 | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run migrations | |
| run: python manage.py makemigrations | |
| - name: Run migrations | |
| run: python manage.py migrate | |
| - name: Run Tests | |
| run: | | |
| python manage.py test | |
| - name: Add remote origin | |
| if: github.event.ref == 'refs/heads/main' && job.status == 'success' | |
| run: | | |
| git remote add heroku https://heroku:${{ secrets.HEROKU_API_KEY }}@git.heroku.com/${{ secrets.HEROKU_APP_NAME }}.git | |
| - name: Deploy to Heroku | |
| run: | | |
| git config --global user.email "my ema...@some.com" | |
| git config --global user.name "Prashanyh" | |
| git config --list | |
| git prune | |
| git remote add upstream projecturl | |
| git pull origin main | |
| git push origin main | |
| git pull heroku main | |
| git push heroku main | |
| git fetch upstream |