Skip to content

Commit f15f103

Browse files
Merge pull request #9 from minvws/add-option-dependabot
Add option to allow sonarscanner on dependabot pr
2 parents 3228b0d + 159a1e3 commit f15f103

2 files changed

Lines changed: 24 additions & 19 deletions

File tree

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ To use the action, add it to a workflow in your repository:
1111
name: Run SonarQube scanner
1212

1313
on:
14-
workflow_dispatch:
15-
pull_request:
16-
push:
17-
branches:
18-
- main
14+
workflow_dispatch:
15+
pull_request:
16+
push:
17+
branches:
18+
- main
1919

2020
jobs:
21-
sonarqube-scanner:
22-
runs-on: ubuntu-latest
23-
steps:
24-
- name: Checkout repository
25-
uses: actions/checkout@v5
26-
27-
- name: Run SonarQube scan
28-
uses: minvws/action-sonarqube@v1
29-
with:
30-
sonar-token: ${{ secrets.SONAR_TOKEN }}
21+
sonarqube-scanner:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v5
26+
27+
- name: Run SonarQube scan
28+
uses: minvws/action-sonarqube@v1
29+
with:
30+
sonar-token: ${{ secrets.SONAR_TOKEN }}
3131
```
3232
3333
Make sure to add the `SONAR_TOKEN` secret to your repository's configuration. See [Using secrets in GitHub Actions](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets).
@@ -38,9 +38,10 @@ In this basic example, the workflow is executed automatically on push to the `ma
3838

3939
The action has the following inputs:
4040

41-
- `sonar-token`: the SonarQube token.
42-
- `project-base-dir`: set the sonar.projectBaseDir analysis property, default is `.`.
43-
- `allow-run-on-fork`: allow SonarQube scan to run on pull requests from forks (default: false).
41+
- `sonar-token` (**required**): The SonarQube token.
42+
- `project-base-dir` (optional): Set the `sonar.projectBaseDir` analysis property. Default is `.`.
43+
- `allow-run-on-fork` (optional): Allow SonarQube scan to run on pull requests from forks. Default is `false`.
44+
- `allow-run-on-dependabot` (optional): Allow SonarQube scan to run on pull requests created by Dependabot. Default is `false`.
4445

4546
## Contribution
4647

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ inputs:
1212
description: 'Allow SonarQube scan to run on pull requests from forks (default: false)'
1313
required: false
1414
default: 'false'
15+
allow-run-on-dependabot:
16+
description: 'Allow SonarQube scan to run on pull requests created by Dependabot (default: false)'
17+
required: false
18+
default: 'false'
1519

1620
runs:
1721
using: "composite"
1822
steps:
1923
- name: 'Run SonarQube scanner'
20-
if: ${{ contains(github.ref, '/pull/') && (github.event.pull_request.head.repo.full_name == github.repository || inputs.allow-run-on-fork == 'true') }}
24+
if: ${{ contains(github.ref, '/pull/') && (github.event.pull_request.head.repo.full_name == github.repository || (inputs.allow-run-on-fork == 'true' && github.actor != 'dependabot[bot]') || (inputs.allow-run-on-dependabot == 'true' && github.actor == 'dependabot[bot]')) }}
2125
uses: SonarSource/sonarqube-scan-action@v5
2226
env:
2327
SONAR_TOKEN: ${{ inputs.sonar-token }}

0 commit comments

Comments
 (0)