-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (89 loc) · 2.63 KB
/
ci.yaml
File metadata and controls
102 lines (89 loc) · 2.63 KB
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
name: CI
on:
pull_request:
branches:
- main
paths-ignore:
- "**.md"
- "**.MD"
push:
branches:
- main
paths-ignore:
- "**.md"
- "**.MD"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Dependencies
run: |
echo "Installing Dependencies..."
pip install -r app/requirements.txt
pip install black flake8 mypy bandit pip-audit
echo "Done"
- name: Lint The Code
run: |
black --check .
mypy .
flake8 .
- name: Security Scan
run: |
echo "Running Security Scan..."
bandit -r app --exclude app/tests
pip-audit
echo "Done"
- name: Run Tests
run: |
echo "Running tests..."
pytest app/tests/
echo "Done"
security:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Scan Dependencies
uses: snyk/actions/python@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high --file=app/requirements.txt --skip-unresolved
- name: Scan Iac
uses: snyk/actions/iac@master
env:
token: ${{ secrets.SNYK_TOKEN }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high
summary-notif:
needs: [build, security]
runs-on: ubuntu-latest
steps:
- name: Discord Notify
if: Always()
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
STATUS=${{ job.status }}
COLOR=$([[ "$STATUS" == "success" ]] && echo "3066993" || echo "15158332")
curl -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"embeds": [{
"title": "CD Pipeline — '"$STATUS"'",
"color": '"$COLOR"',
"fields": [
{ "name": "Repo", "value": "${{ github.repository }}", "inline": true },
{ "name": "Branch", "value": "${{ github.ref_name }}", "inline": true },
{ "name": "Image Tag", "value": "${{ github.sha }}", "inline": false },
{ "name": "Environment", "value": "EKS", "inline": true }
]
}]
}'