Skip to content

Commit 633b821

Browse files
Merge pull request #136 from adobe/issue/fix-sonar-workflow
chore: run sonar on forked prs
2 parents 08e6dc7 + 07c56e4 commit 633b821

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,3 @@ jobs:
3636
path: coverage
3737
- name: Upload code coverage report to codecov.io and comment in pull request
3838
uses: codecov/codecov-action@v3
39-
- name: Upload Sonar report to sonarcloud.io and comment in pull request
40-
uses: sonarsource/sonarcloud-github-action@master
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
44-
with:
45-
args: >
46-
-Dsonar.organization=adobeinc
47-
-Dsonar.projectKey=adobe_aem-react-editable-components
48-
-Dsonar.sources=src
49-
-Dsonar.tests=test
50-
-Dsonar.javascript.lcov.reportPaths=dist/coverage/lcov.info
51-
-Dsonar.coverage.exclusions=src/types.ts

.github/workflows/sonar.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sonar
2+
on:
3+
workflow_run:
4+
workflows: ["Continuous Integration"]
5+
types:
6+
- completed
7+
jobs:
8+
sonar:
9+
name: Sonar
10+
runs-on: ubuntu-latest
11+
if: github.event.workflow_run.conclusion == 'success'
12+
steps:
13+
- name: Checkout source code
14+
uses: actions/checkout@v2
15+
with:
16+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
17+
ref: ${{ github.event.workflow_run.head_branch }}
18+
fetch-depth: 0
19+
- name: "Get PR information"
20+
uses: potiuk/get-workflow-origin@v1_3
21+
id: source-run-info
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
sourceRunId: ${{ github.event.workflow_run.id }}
25+
- name: Upload Sonar report to sonarcloud.io and comment in pull request
26+
uses: sonarsource/sonarcloud-github-action@master
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
30+
with:
31+
args: >
32+
-Dsonar.organization=adobeinc
33+
-Dsonar.projectKey=adobe_aem-react-editable-components
34+
-Dsonar.sources=src
35+
-Dsonar.tests=test
36+
-Dsonar.javascript.lcov.reportPaths=dist/coverage/lcov.info
37+
-Dsonar.coverage.exclusions=src/types.ts
38+
-Dsonar.pullrequest.key=${{ steps.source-run-info.outputs.pullRequestNumber }}
39+
-Dsonar.pullrequest.branch=${{ steps.source-run-info.outputs.sourceHeadBranch }}
40+
-Dsonar.pullrequest.base=${{ steps.source-run-info.outputs.targetBranch }}

0 commit comments

Comments
 (0)