name: OpenSSF Scorecard

on:
  push:
    branches: [main]
  schedule:
    - cron: '0 6 * * 1'

permissions: read-all

jobs:
  analysis:
    name: Scorecard analysis
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      id-token: write
      contents: read
      actions: read

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
        with:
          persist-credentials: false

      - name: Run OpenSSF Scorecard
        uses: ossf/scorecard-action@v2.4.3
        with:
          results_file: results.sarif
          results_format: sarif
          publish_results: true
          repo_token: ${{ secrets.SCORECARD_TOKEN || secrets.GITHUB_TOKEN }}

      - name: Upload Scorecard results to GitHub Security tab
        uses: github/codeql-action/upload-sarif@v4 # tag required by scorecard webapp verification
        with:
          sarif_file: results.sarif
          category: scorecard
