name: "CodeQL"

on:
  workflow_dispatch:
  push:
    branches: [ feat/refresh ]
  pull_request:
    branches: [ feat/refresh ]

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: true
      matrix:
        language: [ 'javascript' ]

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - uses: actions/setup-node@v3
      with:
        node-version: 18
        cache: npm

    - name: Install Dependencies
      run: npm ci
      
    - name: Build Documenso
      run: npm run build

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v2
      with:
        languages: ${{ matrix.language }}

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v2