# synced from @nextcloud/android-config

# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023-2024 Andy Scherzinger <info@andy-scherzinger.de>
# SPDX-FileCopyrightText: 2022 Tobias Kaminsky <tobias@kaminsky.me>
# SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro@alvarobrey.com>
# SPDX-FileCopyrightText: 2025 Marcel Hibbe <dev@mhibbe.de>
# SPDX-License-Identifier: GPL-3.0-or-later

name: "CodeQL"

on:
  push:
    branches: [ "master", "main", "stable-*" ]
  pull_request:
    branches: [ "master", "main" ]
  schedule:
    - cron: '24 18 * * 3'

permissions:
  contents: read

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write
    strategy:
      fail-fast: false
      matrix:
        language: [ 'java' ]
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
      - name: Set Swap Space
        if: runner.environment == 'github-hosted'
        uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0
        with:
          swap-size-gb: 10
      - name: Initialize CodeQL
        uses: github/codeql-action/init@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
        with:
          languages: ${{ matrix.language }}
      - name: Set up JDK 17
        uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
        with:
          distribution: "temurin"
          java-version: 17
      - name: Assemble
        run: |
          mkdir -p "$HOME/.gradle"
          echo "org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
          ./gradlew --no-daemon assembleDebug
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
