Skip to content

Commit f304145

Browse files
committed
Amend SonarCloud GitHub job so that it works with a forked repository
WE2-812 Signed-off-by: Sven Mitt <[email protected]>
1 parent cdcce7a commit f304145

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.github/workflows/maven-build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Maven build
22

3-
on: [ push, pull_request ]
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
types: [ opened, synchronize, reopened ]
48

59
jobs:
610
build:

.github/workflows/sonarcloud-analysis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
name: SonarCloud code analysis
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_run:
5+
workflows: [ "Maven build" ]
6+
types: [ completed ]
47

58
jobs:
69
analyze:
710
name: Analyze
8-
if: github.repository == 'web-eid/web-eid-authtoken-validation-java'
11+
if: >
12+
github.repository == 'web-eid/web-eid-authtoken-validation-java' &&
13+
github.event.workflow_run.conclusion == 'success'
914
runs-on: ubuntu-latest
1015

1116
steps:
1217
- uses: actions/checkout@v4
1318
with:
19+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
20+
ref: ${{ github.event.workflow_run.head_branch }}
1421
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
1522
- name: Set up JDK 17
1623
uses: actions/setup-java@v3

0 commit comments

Comments
 (0)