Set SARIF upload branch to the merge commit ref/sha retrieved from GH CLI (#4958)

This commit is contained in:
Álison Fernandes 2025-04-02 20:32:59 +01:00 committed by GitHub
parent 20bda929b3
commit f43702cb83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 5 deletions

View File

@ -37,8 +37,6 @@ jobs:
uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
with:
sarif_file: cx_result.sarif
sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
quality:
name: Quality scan
@ -60,4 +58,3 @@ jobs:
args: >
-Dsonar.organization=${{ github.repository_owner }}
-Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }}
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}

View File

@ -40,12 +40,27 @@ jobs:
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
--output-path . ${{ env.INCREMENTAL }}
- name: Get branch refs
id: get-branch-refs
env:
GH_TOKEN: ${{ github.token }}
_PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if [[ $GITHUB_EVENT_NAME == "pull_request_target" ]]; then
MERGE_SHA=$(gh api /repos/$GITHUB_REPOSITORY/pulls/$_PR_NUMBER --jq .merge_commit_sha)
echo "SHA=$MERGE_SHA" >> $GITHUB_OUTPUT
echo "REF=refs/pull/$_PR_NUMBER/merge" >> $GITHUB_OUTPUT
else
echo "SHA=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "REF=$GITHUB_REF" >> $GITHUB_OUTPUT
fi
- name: Upload Checkmarx results to GitHub
uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
with:
sarif_file: cx_result.sarif
sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
sha: ${{ steps.get-branch-refs.outputs.SHA }}
ref: ${{ steps.get-branch-refs.outputs.REF }}
quality:
name: Quality scan