name: GitHub Actions Security Analysis (zizmor)

on:
  pull_request:
    branches: ["**"]
    paths:
      - ".github/workflows/**"
  push:
    branches: ["main"]
    paths:
      - ".github/workflows/**"
  workflow_dispatch:

permissions: {}

jobs:
  zizmor_pr_blocking:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      contents: read
      actions: read
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Run zizmor (blocking, HIGH only)
        uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
        with:
          advanced-security: false
          annotations: true
          min-severity: high
          inputs: |
            .github/workflows

  zizmor_main_sarif:
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read
      actions: read
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Run zizmor (SARIF)
        uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
        with:
          inputs: |
            .github/workflows
