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: Python CI | |
on: push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:23.0.3 | |
options: --privileged | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up Python 3.12.0 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.12.0 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 | |
pip install Flask gunicorn pytz | |
pip install pytest | |
- name: Lint code | |
run: | | |
flake8 . | |
- name: Run unit tests | |
run: | | |
pytest | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/my-python-app:latest app_python | |
- name: Push Docker image to registry | |
run: | | |
docker push ${{ secrets.DOCKER_USERNAME }}/my-python-app:latest | |
- name: Install Snyk CLI | |
run: | | |
curl -LO https://github.com/snyk/cli/releases/download/v1.1278.0/snyk-linux | |
chmod +x snyk-linux | |
working-directory: app_python | |
- name: Authenticate and Run Snyk CLI | |
run: | | |
./snyk-linux auth ${{ secrets.SNYK_API_TOKEN }} --severity-threshold=high | |
working-directory: app_python | |
- hosts: all | |
vars: | |
pip_install_packages: | |
- name: docker | |
# roles: | |
# - geerlingguy.pip | |
# - geerlingguy.docker | |