Devsecops #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DevSecOps Workflow | |
on: | |
push: | |
branches: [ main, devsecops ] | |
pull_request: | |
branches: [ main, dev ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
TEST_DATABASE_PREFIX: test_ | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: github_actions | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Unit tests and Linters | |
run: | | |
# Unit Test | |
python manage.py test | |
# Code Formatter | |
black --check . | |
# Import sort | |
isort --check-only . | |
# Lint Flake8 | |
flake8 . | |
- name: Test SCA Vulnerabilities | Static Composition Analysis | |
run: | | |
pyraider check -f requirements.txt | |
- name: Check Package License | |
run: | | |
pip-licenses --format=json > licenses.json | |
./scripts/run-license-compliance.sh | |
- name: Scan for Secrets with Trufflehog | |
run: | | |
trufflehog3 --no-history --format json --output report.json --exclude "env/*" | |
- name: Build an image from Dockerfile | |
run: | | |
docker build -t built-image:scan . | |
- name: Run dockle | |
uses: goodwithtech/dockle-action@main | |
with: | |
image: 'built-image:scan' | |
format: 'list' | |
exit-code: '1' | |
exit-level: 'warn' | |
ignore: 'CIS-DI-0001,DKL-DI-0006,DKL-DI-0005,CIS-DI-0010,CIS-DI-0007' |