Skip to content

Commit 5914ca9

Browse files
Add Sonar support for forked PRs
1 parent 3752107 commit 5914ca9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/sonar.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Sonar
33
push:
44
branches:
55
- main
6-
pull_request:
6+
pull_request_target:
77
branches:
88
- main
99
schedule:
@@ -16,6 +16,11 @@ jobs:
1616
- uses: actions/checkout@v2
1717
with:
1818
fetch-depth: 0
19+
- name: Check for external PR
20+
if: ${{ !(contains(github.event.pull_request.labels.*.name, 'safe') ||
21+
github.event.pull_request.head.repo.full_name == github.repository ||
22+
github.event_name != 'pull_request_target') }}
23+
run: echo "Unsecure PR, must be labelled with the 'safe' label, then run the workflow again" && exit 1
1924
- name: Set up Python 3.8
2025
uses: actions/setup-python@v2
2126
with:
@@ -33,4 +38,4 @@ jobs:
3338
uses: SonarSource/sonarcloud-github-action@master
3439
env:
3540
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
36-
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
41+
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'

0 commit comments

Comments
 (0)