fix: remove unsupported working-directory in snyk step #3
This file contains hidden or 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 | ||
|
Check failure on line 1 in .github/workflows/python-ci.yml
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - lab03 | ||
| paths: | ||
| - "app_python/**" | ||
| - ".github/workflows/python-ci.yml" | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| paths: | ||
| - "app_python/**" | ||
| - ".github/workflows/python-ci.yml" | ||
| permissions: | ||
| contents: read | ||
| concurrency: | ||
| group: python-ci-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| env: | ||
| PIP_DISABLE_PIP_VERSION_CHECK: "1" | ||
| jobs: | ||
| lint-test: | ||
| name: Lint and test (Python ${{ matrix.python-version }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: true | ||
| matrix: | ||
| python-version: ["3.11", "3.12"] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: "pip" | ||
| cache-dependency-path: app_python/requirements.txt | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r app_python/requirements.txt | ||
| - name: Lint (ruff) | ||
| run: python -m ruff check app_python | ||
| - name: Run tests | ||
| run: python -m pytest -v app_python/tests | ||
| - name: Snyk security scan | ||
| if: matrix.python-version == '3.12' && github.event_name == 'push' && secrets.SNYK_TOKEN != '' | ||
| uses: snyk/actions/python@v3 | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| with: | ||
| args: --severity-threshold=high --file=app_python/requirements.txt | ||
| docker-build-push: | ||
| name: Build and push Docker image | ||
| runs-on: ubuntu-latest | ||
| needs: lint-test | ||
| if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/lab03') | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Set image version | ||
| run: | | ||
| CALVER=$(date +"%Y.%m") | ||
| VERSION="${CALVER}.${GITHUB_RUN_NUMBER}" | ||
| echo "CALVER=${CALVER}" >> $GITHUB_ENV | ||
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | ||
| echo "IMAGE_NAME=pepegx/devops-info-service" >> $GITHUB_ENV | ||
| - name: Build and push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: app_python | ||
| file: app_python/Dockerfile | ||
| push: true | ||
| tags: | | ||
| ${{ env.IMAGE_NAME }}:${{ env.VERSION }} | ||
| ${{ env.IMAGE_NAME }}:${{ env.CALVER }} | ||
| ${{ env.IMAGE_NAME }}:latest | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||