@@ -19,25 +19,24 @@ jobs:
19192020
2121 - uses : actions/github-script@v6
22- id : get_pr_data
22+ id : get_pr_number
2323 with :
2424 script : |
25- return (
26- await github.rest.repos.listPullRequestsAssociatedWithCommit({
27- commit_sha: context.sha,
28- owner: context.repo.owner,
29- repo: context.repo.repo,
30- })
31- ).data[0];
32-
33- - uses : ./.github/actions/bootstrap
34- env :
35- INSTALL_SONAR : true
36- SKIP_MINT_BOOTSTRAP : true
25+ const prs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
26+ commit_sha: context.sha,
27+ owner: context.repo.owner,
28+ repo: context.repo.repo,
29+ });
30+ return prs.data[0]?.number || '';
3731
3832 - name : Run Sonar analysis
3933 run : |
40- ARTIFACT_NAME="test-coverage-${{ fromJson(steps.get_pr_data.outputs.result).number }}"
34+ if [[ -z "${{ steps.get_pr_number.outputs.result }}" ]]; then
35+ echo "No PR found. Skipping Sonar analysis."
36+ exit 0
37+ fi
38+
39+ ARTIFACT_NAME="test-coverage-${{ steps.get_pr_number.outputs.result }}"
4140 ARTIFACT=$(gh api repos/${{ github.repository }}/actions/artifacts | jq -r ".artifacts | map(select(.name==\"$ARTIFACT_NAME\")) | first")
4241 if [[ "$ARTIFACT" == null || "$ARTIFACT" == "" ]]; then
4342 echo "Artifact not found. Skipping Sonar analysis."
0 commit comments