ci: trigger workflow for k8s changes #10
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 (Lab03) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| - "lab*" | |
| paths: | |
| - "app_python/**" | |
| - "monitoring/**" | |
| - "ansible/**" | |
| - "k8s/**" | |
| - "playbooks/**" | |
| - ".github/workflows/python-ci.yml" | |
| pull_request: | |
| paths: | |
| - "app_python/**" | |
| - "monitoring/**" | |
| - "ansible/**" | |
| - "k8s/**" | |
| - "playbooks/**" | |
| - ".github/workflows/python-ci.yml" | |
| concurrency: | |
| group: python-ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-lint: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: app_python | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| cache-dependency-path: "app_python/requirements.txt" | |
| - name: Install deps | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Lint (ruff) | |
| run: ruff check . | |
| - name: Tests | |
| run: pytest -q | |
| docker-build-push: | |
| needs: test-lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set version (CalVer) | |
| run: | | |
| echo "CALVER=$(date +%Y.%m)" >> $GITHUB_ENV | |
| echo "BUILD=${{ github.run_number }}" >> $GITHUB_ENV | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build & Push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./app_python | |
| file: ./app_python/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKER_USERNAME }}/devops-lab02-python:${{ env.CALVER }}.${{ env.BUILD }} | |
| ${{ secrets.DOCKER_USERNAME }}/devops-lab02-python:latest |