on:
  workflow_dispatch:
  schedule:
  - cron: 0 6 * * *
  push:
    branches:
    - main
    paths:
    - .github/workflows/codeql-analysis.yml

permissions: {}

name: codeql analysis
jobs:
  csharp:
    name: CodeQL analysis (C#)
    runs-on: windows-2022

    permissions:
      contents: read
      packages: read
      security-events: write

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

      - name: Install NuGet
        run: ./install.nuget.cmd
        working-directory: build/windows

      - name: Create nuget.config
        run: ./create-nuget-config.cmd "dlemstra" "${{ secrets.GITHUB_TOKEN }}"
        working-directory: src/Magick.Native

      - name: Install Magick.Native
        run: ./install.cmd
        working-directory: src/Magick.Native

      - name: Initialize CodeQL
        uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 #4.35.2
        with:
          languages: csharp

      - name: Build Magick.NET (Release)
        run: ./build.Magick.NET.cmd Q16-HDRI "x64" Release
        working-directory: build/windows

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 #4.35.2

  actions:
    name: CodeQL analysis (GitHub Actions)
    runs-on: ubuntu-24.04

    permissions:
      contents: read
      security-events: write

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

      - name: Initialize CodeQL
        uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 #4.35.2
        with:
          languages: actions

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 #4.35.2
