name: "CodeQL Analysis"

on:
  push:
    branches: [ trunk ]
  pull_request:
    branches: [ trunk ]
  schedule:
    - cron: '0 3 * * *'

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        language: [ 'python' ]

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

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

    - name: Autobuild
      uses: github/codeql-action/autobuild@v1

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

name: "CodeQL Analysis"

on:
  push:
    branches: [ trunk ]
  pull_request:
    branches: [ trunk ]
  schedule:
    - cron: '0 3 * * *'

jobs:
  # Special job which skips duplicate jobs
  pre_job:
    name: Skip Duplicate Jobs Pre Job
    runs-on: ubuntu-latest
    # Map a step output to a job output
    outputs:
      should_skip: ${{ steps.skip_check.outputs.should_skip }}
    steps:
      - name: Checkout code
        uses: actions/checkout@master
        with:
          persist-credentials: false
          submodules: recursive

      - id: skip_check
        # NOTE: We store action as submodule since ASF doesn't allow directly referencing external
        # actions
        uses: ./.github/actions/skip-duplicate-actions # v3.4.0
        with:
          github_token: ${{ github.token }}

  analyze:
    name: Analyze
    runs-on: ubuntu-latest

    needs: pre_job
    if: ${{ needs.pre_job.outputs.should_skip == 'false' || github.ref == 'refs/heads/trunk' }}

    strategy:
      fail-fast: false
      matrix:
        language: [ 'python' ]

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

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

    - name: Autobuild
      uses: github/codeql-action/autobuild@v1

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

Add skip duplicates pre job to CodeQL workflow.
Add skip duplicates pre job to CodeQL workflow.
