-
Notifications
You must be signed in to change notification settings - Fork 2
103 lines (85 loc) · 2.38 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
---
name: Build Image (Dockerhub)
on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'docs/**'
- '.github/**'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r ./requirements.txt
pip install pylint
pip install mypy
- name: Analysing the code with pylint
run: |
python -m pylint `ls -R|grep .py$|xargs`
- name: Analysing the code with MyPy
run: |
python -m mypy *.py
analyze:
name: Analyze
runs-on: ubuntu-latest
needs: [lint]
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
build:
name: Build and Push to Docker Hub
environment: DOCKERHUB
runs-on: ubuntu-latest
needs: [lint, analyze]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login on DockerHub
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} \
-p ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
run: |
docker build --no-cache --rm \
-t ${{ github.repository }}:v0.${{ github.run_number }} \
-f ./Dockerfile .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ github.repository }}:v0.${{ github.run_number }}'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
- name: Push to DockerHub
run: docker push ${{ github.repository }}:v0.${{ github.run_number }}