name: zizmor

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["**"]

permissions:
  contents: read # Needed to checkout the repository.

concurrency:
  group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.sha }}"
  cancel-in-progress: true

jobs:
  zizmor:
    name: zizmor
    runs-on: ubuntu-latest
    permissions:
      security-events: write # Needed to upload code scanning results.
      contents: read # Needed to checkout the repository.
      actions: read # Needed to analyze action metadata.
    steps:
    - name: harden runner
      uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
      with:
        egress-policy: audit

    - name: checkout
      uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
      with:
        persist-credentials: false

    - name: setup uv
      uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7.1.1

    - name: zizmor
      run: uvx zizmor --pedantic --format sarif . > results.sarif
      env:
        GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

    - name: upload
      uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
      with:
        sarif_file: results.sarif
        category: zizmor
