|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +env: |
| 8 | + IMAGE_NAME: ${{ github.repository }} |
| 9 | + |
| 10 | + |
| 11 | +jobs: |
| 12 | + ruff_lint: |
| 13 | + name: Ruff Lint |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + continue-on-error: ${{ github.ref != 'refs/heads/main' && !(github.event_name == 'pull_request' && github.base_ref == 'main') }} |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Run Ruff |
| 22 | + uses: astral-sh/ruff-action@v3 |
| 23 | + with: |
| 24 | + version: "0.14.2" |
| 25 | + args: "check --config pyproject.toml qazpt" |
| 26 | + |
| 27 | + pip_audit: |
| 28 | + name: pip-audit |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + continue-on-error: ${{ github.ref != 'refs/heads/main' && !(github.event_name == 'pull_request' && github.base_ref == 'main') }} |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: "3.14" |
| 40 | + |
| 41 | + - name: Run pip-audit |
| 42 | + uses: pypa/gh-action-pip-audit@v1.1.0 |
| 43 | + with: |
| 44 | + inputs: . |
| 45 | + |
| 46 | + build_and_push: |
| 47 | + name: Build and Push Docker Image |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: [ruff_lint, pip_audit] |
| 50 | + |
| 51 | + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') |
| 52 | + permissions: |
| 53 | + contents: read |
| 54 | + packages: write |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Set up QEMU |
| 61 | + uses: docker/setup-qemu-action@v3 |
| 62 | + with: |
| 63 | + platforms: arm64 |
| 64 | + |
| 65 | + - name: Set up Docker Buildx |
| 66 | + uses: docker/setup-buildx-action@v3 |
| 67 | + |
| 68 | + - name: Log in to GitHub Container Registry |
| 69 | + uses: docker/login-action@v3 |
| 70 | + with: |
| 71 | + registry: ghcr.io |
| 72 | + username: ${{ github.actor }} |
| 73 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + - name: Extract Docker metadata |
| 76 | + id: meta |
| 77 | + uses: docker/metadata-action@v5 |
| 78 | + with: |
| 79 | + images: ghcr.io/${{ env.IMAGE_NAME }} |
| 80 | + tags: | |
| 81 | + type=semver,pattern={{version}} |
| 82 | + type=raw,value=latest |
| 83 | + type=sha |
| 84 | +
|
| 85 | + - name: Build and push Docker image |
| 86 | + uses: docker/build-push-action@v6 |
| 87 | + with: |
| 88 | + context: . |
| 89 | + push: true |
| 90 | + platforms: linux/amd64,linux/arm64 |
| 91 | + tags: ${{ steps.meta.outputs.tags }} |
| 92 | + labels: ${{ steps.meta.outputs.labels }} |
| 93 | + cache-from: type=gha |
| 94 | + cache-to: type=gha,mode=max |
0 commit comments