|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Enable Buildkit and let compose use it to speed up image building |
| 4 | +env: |
| 5 | + DOCKER_BUILDKIT: 1 |
| 6 | + COMPOSE_DOCKER_CLI_BUILD: 1 |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - 'feat/**' |
| 12 | + - 'ci/**' |
| 13 | + - 'issue/**' |
| 14 | + - 'master' |
| 15 | + - 'develop' |
| 16 | + - 'hotfix/**' |
| 17 | + - 'bug/**' |
| 18 | + - 'fix/**' |
| 19 | + - 'refactor/**' |
| 20 | + - 'build/**' |
| 21 | + - 'test/**' |
| 22 | + |
| 23 | + |
| 24 | +jobs: |
| 25 | + precommit: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Setup Python |
| 29 | + |
| 30 | + with: |
| 31 | + python-version: 3.8.7 |
| 32 | + architecture: x64 |
| 33 | + - name: Checkout Repository |
| 34 | + uses: actions/checkout@main |
| 35 | + - name: Install dependencies |
| 36 | + run: pip install -r requirements/local.txt |
| 37 | + - name: Run precommit |
| 38 | + run: pre-commit run --all-files |
| 39 | + |
| 40 | +# With no caching at all the entire ci process takes 4m 30s to complete! |
| 41 | + unittest: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Checkout Code Repository |
| 45 | + uses: actions/checkout@v2 |
| 46 | + - name: Build the Stack |
| 47 | + run: docker-compose -f local.yml build |
| 48 | + - name: Make DB Migrations |
| 49 | + run: docker-compose -f local.yml run --rm django python manage.py migrate |
| 50 | + - name: Run the Stack |
| 51 | + run: docker-compose -f local.yml up -d |
| 52 | + - name: Run Django Tests |
| 53 | + run: docker-compose -f local.yml exec -T django coverage run --rcfile=.pre-commit/setup.cfg -m pytest --disable-pytest-warnings; |
| 54 | + - name: Print Coverage |
| 55 | + run: docker-compose -f local.yml exec -T django coverage report |
| 56 | + - name: Tear down the Stack |
| 57 | + run: docker-compose -f local.yml down |
| 58 | + |
| 59 | + deploy: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' |
| 62 | + needs: |
| 63 | + - unittest |
| 64 | + - precommit |
| 65 | + steps: |
| 66 | + - name: Checkout Repository |
| 67 | + uses: actions/checkout@v1 |
| 68 | + |
| 69 | + - name: Push to Staging |
| 70 | + if: github.ref == 'refs/heads/develop' |
| 71 | + uses: akhileshns/[email protected] |
| 72 | + |
| 73 | + with: |
| 74 | + heroku_api_key: ${{ secrets.HEROKU_API_KEY }} |
| 75 | + heroku_app_name: ${{ secrets.HEROKU_STG_APP_NAME }} |
| 76 | + heroku_email: ${{ secrets.HEROKU_EMAIL }} |
| 77 | + |
| 78 | + |
| 79 | + - name: Push to Production |
| 80 | + if: github.ref == 'refs/heads/master' |
| 81 | + uses: akhileshns/[email protected] |
| 82 | + |
| 83 | + with: |
| 84 | + heroku_api_key: ${{ secrets.HEROKU_API_KEY }} |
| 85 | + heroku_app_name: ${{ secrets.HEROKU_PROD_APP_NAME }} |
| 86 | + heroku_email: ${{ secrets.HEROKU_EMAIL }} |
| 87 | + |
| 88 | + |
| 89 | + bump: |
| 90 | + if: "github.event_name == 'push' && github.ref == 'refs/heads/master'" |
| 91 | + runs-on: ubuntu-latest |
| 92 | + needs: |
| 93 | + - unittest |
| 94 | + - precommit |
| 95 | + - deploy |
| 96 | + steps: |
| 97 | + - name: Checkout Repository |
| 98 | + uses: actions/checkout@main |
| 99 | + - name: Install dependencies |
| 100 | + |
| 101 | + with: |
| 102 | + node-version: '12.x' |
| 103 | + - name: Install dependencies |
| 104 | + run: yarn install |
| 105 | + - name: Release |
| 106 | + |
| 107 | + env: |
| 108 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' |
| 109 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + run: npx semantic-release |
| 111 | + |
0 commit comments