Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
535ef95
Organizing the git repo
boyanaboneva Nov 23, 2024
47fecfe
Added GitLeaks scan for secrets and EditorConfig Checker
boyanaboneva Nov 23, 2024
7e411e1
Added pylint
boyanaboneva Nov 23, 2024
5d1101b
Added Python Black
boyanaboneva Nov 23, 2024
57fa644
remove a line path
boyanaboneva Nov 23, 2024
a826cca
added Markdownlint CLI
boyanaboneva Nov 24, 2024
be56bb5
added unittests
boyanaboneva Nov 24, 2024
cb8c44e
updated unittests
boyanaboneva Nov 24, 2024
169537c
updated unittests
boyanaboneva Nov 24, 2024
4457217
added sonarcloud
boyanaboneva Nov 24, 2024
371928b
updated sonarcloud
boyanaboneva Nov 24, 2024
c2bdcc7
updated sonarcloud
boyanaboneva Nov 24, 2024
b54f0f3
updated sonarcloud projectkey
boyanaboneva Nov 24, 2024
875dfd4
added Snyk
boyanaboneva Nov 24, 2024
6f56e8b
updated Snyk
boyanaboneva Nov 24, 2024
5e042e9
updated Snyk
boyanaboneva Nov 24, 2024
8caafd8
updated Snyk
boyanaboneva Nov 24, 2024
7821736
updated Snyk
boyanaboneva Nov 24, 2024
5aabb97
updated Snyk
boyanaboneva Nov 24, 2024
9d5ee1b
updated Snyk
boyanaboneva Nov 24, 2024
f1a69fa
updated Snyk
boyanaboneva Nov 25, 2024
7708855
updated Snyk
boyanaboneva Nov 25, 2024
0d090cb
added docker image
boyanaboneva Nov 25, 2024
265f0f9
added dependency in the docker image
boyanaboneva Nov 25, 2024
a501f9b
added build docker image
boyanaboneva Nov 25, 2024
c246f33
updated build docker image
boyanaboneva Nov 25, 2024
b6cb4c9
updated build docker image with tag
boyanaboneva Nov 25, 2024
502864a
updated build docker image
boyanaboneva Nov 25, 2024
7a0baf6
updated docker tags
boyanaboneva Nov 25, 2024
b51f064
updated docker tags
boyanaboneva Nov 25, 2024
8e91f19
updated uses
boyanaboneva Nov 25, 2024
8e2666b
updated secrets
boyanaboneva Nov 25, 2024
4f58b40
added trivy
boyanaboneva Nov 25, 2024
7cf33b2
updated trivy
boyanaboneva Nov 25, 2024
2533a89
updated trivy severity
boyanaboneva Nov 25, 2024
d9c7242
removed trivy severity
boyanaboneva Nov 25, 2024
2e9283d
updated trivy scan
boyanaboneva Nov 25, 2024
21218a5
updated trivy scan
boyanaboneva Nov 25, 2024
9a1945b
updated trivy scan
boyanaboneva Nov 25, 2024
825a2b3
added trivy cache
boyanaboneva Nov 25, 2024
78e7525
removed trivy cache & exit-code
boyanaboneva Nov 25, 2024
437d87a
added docker push
boyanaboneva Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions .github/workflows/M1-4-2-CI-Practice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Flask App GitHub Actions Pipeline
run-name: Flask App GitHub Actions Pipeline

on:
push:
branches:
- feature/M1-4-2-CI-Practice
pull_request:
branches:
- main

jobs:
gitleaks-scan:
name: GitLeaks scan for secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

editorconfig:
name: EditorConfig Checker
runs-on: ubuntu-latest
needs: gitleaks-scan
steps:
- uses: actions/checkout@v4
- uses: editorconfig-checker/action-editorconfig-checker@main
- run: editorconfig-checker

python-pylint:
name: Executes pylint
runs-on: ubuntu-latest
needs: gitleaks-scan
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Lint
uses: gabriel-milan/action-pylint@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} # GitHub token
path: "./*.py" # Glob pattern for files to lint
fail: true # Fail the action if pylint errors are found
pr-message: true # Send a PR message if pylint errors are found

python-black:
name: Python Black
runs-on: ubuntu-latest
needs: gitleaks-scan
steps:
- uses: actions/checkout@v3
- name: Python Black
uses: cytopia/[email protected]

markdownlint-cli:
name: Markdownlint CLI
runs-on: ubuntu-latest
needs: gitleaks-scan
steps:
- name: Install Markdownlint CLI
run: npm install -g markdownlint-cli

- name: Run Markdownlint
run: markdownlint **/*.md

unittests:
name: Unit Tests
runs-on: ubuntu-latest
needs: gitleaks-scan
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run unit tests
run: python -m unittest discover -s app -p "*.py"

sonarcloud:
name: Sonarcloud scan
runs-on: ubuntu-latest
needs: [gitleaks-scan, editorconfig, python-pylint, python-black, markdownlint-cli, unittests]
steps:
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: SonarCloud Scan
uses: sonarsource/[email protected]
with:
args: >
-Dsonar.organization=boyanaboneva
-Dsonar.projectKey=boyanaboneva_devops-programme
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

snyk:
name: Snyk scan
runs-on: ubuntu-latest
needs: [gitleaks-scan, editorconfig, python-pylint, python-black, markdownlint-cli, unittests]
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/python@master
continue-on-error: true # To make sure that SARIF upload gets called
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high

docker-trivy:
runs-on: ubuntu-latest
needs: [unittests, snyk, sonarcloud]
permissions:
contents: read
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: ${{ secrets.DOCKERHUB_USERNAME }}/flaskapp:${{ github.sha }}

- name: Trivy scan
uses: aquasecurity/[email protected]
with:
image-ref: ${{ secrets.DOCKERHUB_USERNAME }}/flaskapp:${{ github.sha }}
format: "table"
ignore-unfixed: true
vuln-type: "os,library"
severity: 'CRITICAL,HIGH'

- name: Push docker image
if: ${{ success() }}
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/flaskapp:${{ github.sha }}



5 changes: 5 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
***GitHub Actions README***

To run ***github_actions_hw.yml*** workflow, any change should be done in the README.md file and should be
commited and pushed to GitHub. Then a PR should be made to the main branch and merged. It will trigger the
Actions tab in GitHub.
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# devops-programme

To run the playbook_docker.yml, execute the bellow command:
```
ansible-playbook playbook_docker.yml
```

To run the ansible playbook with encrypted docker credentials and push the image to Docker Hub, execute:
```
ansible-playbook --ask-vault-pass playbook_docker.yml
```

To build the docker image, execute:
```
docker build -t bobby84/getting-started-index-html .
Expand All @@ -23,18 +13,4 @@ docker image ls
To push the docker image to Docker Hub, execute:
```
docker push bobby84/getting-started-index-html
```

To run the playbook_docker.yml, execute the bellow command:
```
ansible-playbook playbook_docker.yml
```

To run the ansible playbook with encrypted docker credentials and push the image to Docker Hub, execute:
```
ansible-playbook --ask-vault-pass playbook_docker.yml
```

To run ***github_actions_hw.yml*** workflow, any change should be done in the README.md file and should be
commited and pushed to GitHub. Then a PR should be made to the main branch and merged. It will trigger the
Actions tab in GitHub.
```
11 changes: 11 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
***ANSIBLE README***

To run the playbook_docker.yml, execute the bellow command:
```
ansible-playbook playbook_docker.yml
```

To run the ansible playbook with encrypted docker credentials and push the image to Docker Hub, execute:
```
ansible-playbook --ask-vault-pass playbook_docker.yml
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading