name: "CodeQL"

on:
  push:
    branches: ["master", "1.23.X"]
  pull_request:
    branches: ["master", "1.23.X"]
  schedule:
    - cron: "16 22 * * 0"

jobs:
  analyze:
    # Only run scheduled analysis on the original repository, not on forks
    if: github.event_name != 'schedule' || github.repository == 'louislam/uptime-kuma'
    name: Analyze
    runs-on: ubuntu-latest
    timeout-minutes: 360

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

    strategy:
      fail-fast: false
      matrix:
        language: ["go", "javascript-typescript"]

    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with: { persist-credentials: false }

      # Initializes the CodeQL tools for scanning.
      - name: Initialize CodeQL
        uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
        with:
          languages: ${{ matrix.language }}

      - name: Autobuild
        uses: github/codeql-action/autobuild@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
        with:
          category: "/language:${{matrix.language}}"
  zizmor:
    # Only run scheduled analysis on the original repository, not on forks
    if: github.event_name != 'schedule' || github.repository == 'louislam/uptime-kuma'
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read
      actions: read
    steps:
      - name: Checkout repository
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with: { persist-credentials: false }
      - name: Run zizmor
        uses: zizmorcore/zizmor-action@e639db99335bc9038abc0e066dfcd72e23d26fb4 # v0.3.0
