-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (69 loc) · 2.23 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
name: CI
on:
pull_request:
branches: [ "main" ]
paths-ignore: [ "docs/**" ]
push:
branches: [ "main" ]
paths-ignore: [ "docs/**" ]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
concurrency:
group: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.event_name }}
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- run: pip install -r src/requirements.txt
- name: Run pre-commit
uses: pre-commit/[email protected]
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Prepare env vars
run: echo '${{ secrets.ENV_LOCAL }}' | base64 -d > src/.env.local
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- run: pip install -r src/requirements.txt
- name: Run tests
run: make test
deploy:
name: Deploy
concurrency: "deploy-step" # Only one deploy job at any time
runs-on: ubuntu-latest
needs: [ linter, pytest ]
if: ${{ !contains(github.event.head_commit.message, '#skip-deploy') && github.ref == 'refs/heads/main' }}
steps:
- name: Git clone the repository
uses: actions/checkout@v4
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::256842052552:role/chalice-project-deploy
aws-region: ap-southeast-2
- name: Prepare env vars
run: >
echo '${{ secrets.ENV_PROD }}' | base64 -d > src/.env.prod &&
echo '${{ secrets.ENV_LOCAL }}' | base64 -d > src/.env.local
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- run: pip install -r src/requirements.txt
- name: Deploy
run: make deploy
- name: Cleanup
# Run even if deploy failed
if: ${{ ! cancelled() }}
run: rm src/.env*