on:
  workflow_dispatch:
  schedule:
  - cron: 0 7 * * 1
  push:
    branches:
    - main
    paths:
    - .github/workflows/scorecard-analysis.yml
  pull_request:
    branches:
    - main

permissions: read-all

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

    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1
        with:
          persist-credentials: false

      - name: Run analysis
        uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a #v2.4.3
        with:
          results_file: results.sarif
          results_format: sarif
          publish_results: ${{ github.event_name != 'pull_request' }}

      - name: Upload to code-scanning
        if: github.event_name != 'pull_request'
        uses: github/codeql-action/upload-sarif@7188fc363630916deb702c7fdcf4e481b751f97a #4.37.1
        with:
          sarif_file: results.sarif
