CodeQL #220
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CodeQL | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- '**/*.java' | |
- '.github/workflows/codeql.yaml' | |
pull_request: | |
branches: [ master ] | |
paths: | |
- '**/*.java' | |
- '.github/workflows/codeql.yaml' | |
schedule: | |
- cron: '0 1 * * *' # daily at 1am UTC | |
jobs: | |
analyze: | |
name: Analyze | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for accurate comparisons | |
- name: Check for Java file changes | |
id: java_changes | |
run: | | |
git fetch origin master --prune | |
if git diff --name-only HEAD HEAD~1 | grep -E '\.java$'; then | |
echo "Java files have changed." | |
echo "java_changed=true" >> $GITHUB_ENV | |
else | |
echo "No Java file changes detected." | |
echo "java_changed=false" >> $GITHUB_ENV | |
fi | |
- name: Setup JDK 22 | |
if: env.java_changed == 'true' | |
uses: actions/setup-java@v4 | |
with: | |
cache: 'maven' | |
distribution: 'temurin' | |
java-version: '22' | |
- name: Initialize CodeQL | |
if: env.java_changed == 'true' | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: 'java' | |
- name: Autobuild | |
if: env.java_changed == 'true' | |
run: mvn -B package --file pom.xml | |
- name: Perform CodeQL Analysis | |
if: env.java_changed == 'true' | |
uses: github/codeql-action/analyze@v3 |