run migrations before the tests and changed to a different version of… #9
This file contains hidden or 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: Git flow CI | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| - 'feature/*' | |
| - 'release/*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:13 | |
| env: | |
| POSTGRES_USER: ${{ secrets.DB_USER }} | |
| POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| POSTGRES_DB: ${{ secrets.DB_NAME }} | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run migrations | |
| env: | |
| DJANGO_SETTINGS_MODULE: "Videogames_project.settings" | |
| DB_NAME: ${{ secrets.DB_NAME }} | |
| DB_USER: ${{ secrets.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| DB_HOST: localhost | |
| DB_PORT: "5432" | |
| run: | | |
| python manage.py migrate --noinput | |
| - name: Run tests | |
| env: | |
| DJANGO_SETTINGS_MODULE: "Videogames_project.settings" | |
| DB_NAME: ${{ secrets.DB_NAME }} | |
| DB_USER: ${{ secrets.DB_USER }} | |
| DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| DB_HOST: localhost | |
| DB_PORT: "5432" | |
| run: | | |
| python manage.py test --verbosity=2 | |
| release: | |
| name: Set the Release Tag | |
| if: github.ref == 'refs/heads/release/*' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create release tag | |
| env: | |
| GIT_TAG: "v$(date +'%Y.%m.%d.%H%M')" | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag $GIT_TAG | |
| git push origin $GIT_TAG |