grafana/.github/workflows/pr-codeql-analysis-python.yml

49 lines
1.2 KiB
YAML

name: "CodeQL for PR / python"
on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- '**/*.py'
permissions:
security-events: write
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
if: github.repository == 'grafana/grafana'
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
persist-credentials: false
- name: Check for Python files
id: check-python
run: |
if [ -z "$(find . -name '*.py' -type f)" ]; then
echo "No Python files found, skipping analysis"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "Python files found, proceeding with analysis"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
if: steps.check-python.outputs.skip != 'true'
uses: github/codeql-action/init@v4
with:
languages: "python"
- name: Perform CodeQL Analysis
if: steps.check-python.outputs.skip != 'true'
uses: github/codeql-action/analyze@v4