Improve Qodana workflow: adjust checkout logic and enable PR-specific reporting

- Use separate checkout steps for pull_request events and other event types
- Enable Qodana PR-specific reporting conditionally for pull_request events
This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-11-29 03:54:13 -03:00
parent a0bf000edc
commit 78f8e08bb9
1 changed files with 14 additions and 3 deletions

View File

@ -17,14 +17,25 @@ jobs:
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
# Checkout for pull_request events: use the PR head SHA for accurate analysis
- name: Checkout (pull_request)
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 # a full history is required for pull request analysis
# Checkout for push and other events (e.g., merges to develop): use the current commit
- name: Checkout (push/other)
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.2
with:
pr-mode: false
# Enable PR-specific reporting only for pull_request events
pr-mode: ${{ github.event_name == 'pull_request' }}
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_268690425 }}
QODANA_ENDPOINT: 'https://qodana.cloud'