Skip to content

Commit

Permalink
A pull request analysis cannot have the branch analysis parameter 'so…
Browse files Browse the repository at this point in the history
…nar.branch.name'
  • Loading branch information
itsankit-google committed Aug 29, 2024
1 parent fd59e3b commit 05a477b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-sonar-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
BRANCH: ${{ github.event.workflow_run.head_branch }}
run: >-
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -fae -T 2 -B -V
-Dmaven.repo.local=$HOME/.m2/repository11
Expand All @@ -61,7 +60,6 @@ jobs:
-Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }}
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}
-Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}
-Dsonar.branch.name=$BRANCH
- name: Sonar report
if: ${{ github.event.workflow_run.pull_requests[0].head.ref == github.event.workflow_run.pull_requests[0].base.ref }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build-sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ jobs:
build:
runs-on: k8s-runner-build

# We allow builds:
# 1) When it's a merge into a branch
# 2) For PRs that are labeled as build and
# - It's a code change
# - A build label was just added
# A bit complex, but prevents builds when other labels are manipulated
if: >
github.event_name == 'push'
|| (contains(github.event.pull_request.labels.*.name, 'build')
&& (github.event.action != 'labeled' || github.event.label.name == 'build')
)
steps:
- uses: actions/checkout@v3
with:
Expand Down

0 comments on commit 05a477b

Please sign in to comment.