Skip to content

fix workflow

fix workflow #15

Workflow file for this run

name: Python CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app_python
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: 'pip'
python-version: '3.12'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint flake8
run: |
flake8 app.py tests --count --max-complexity=15 --max-line-length=127 --statistics
- name: Testing with pytest
run: |
pytest tests/ --doctest-modules --junitxml=junit/test-results.xml
push_to_docker:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
defaults:
run:
working-directory: ./app_python
steps:
- name: Check out the repo
uses: actions/checkout@v5
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: bulatgazizov/python_app
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./app_python
file: ./app_python/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Snyk CLI
run: |
curl https://downloads.snyk.io/cli/stable/snyk-linux -o snyk-linux
curl https://downloads.snyk.io/cli/stable/snyk-linux.sha256 -o snyk.sha256
sha256sum -c snyk.sha256
chmod +x snyk-linux
sudo mv snyk-linux /usr/local/bin/snyk
- name: Run Snyk to test project dependencies
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: |
cd app_python
pip install -r requirements.txt --break-system-packages
snyk test