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