From 383c713c2ef7d08596fee5c0e0720e8ac8fceeba Mon Sep 17 00:00:00 2001 From: Nancy Enos Date: Sat, 23 Nov 2024 13:44:35 +0300 Subject: [PATCH] Only run CodeQL python if the PR contains changed files that are python Ticket: #7358 --- .github/workflows/codeql.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9717f8762d0a..551dc463f280 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -39,13 +39,24 @@ jobs: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + # Check if Python files are changed + - name: Check for Python file changes + id: python_check + run: | + git fetch origin ${{ github.base_ref }} + git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep '^python/' || echo "no-python-changes" + continue-on-error: true + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3.27.0 with: languages: ${{ matrix.language }} queries: security-extended - + if: | + (matrix.language == 'cpp') || + (matrix.language == 'python' && steps.python_check.outputs.result != 'no-python-changes') + - run: | sudo apt-get update sudo apt-get install libyaml-dev