Skip to content

Commit c1d96b7

Browse files
committed
Use same job for pull requests
1 parent a81ea79 commit c1d96b7

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,26 @@ on:
1414

1515
jobs:
1616
build:
17-
if: github.event_name != 'release' && endsWith(github.ref, '/master') == true
17+
if: github.event_name != 'release'
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
2123
- name: Set up JDK 11
2224
uses: actions/setup-java@v1
2325
with:
2426
java-version: 11
2527
- name: Grant execute permission for gradlew
2628
run: chmod +x gradlew
27-
- name: Execute build test and jacocoTestReport
29+
- name: Execute build test jacocoTestReport and sonar analysis
30+
if: endsWith(github.REF, '/master') == true
2831
env:
2932
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3033
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
31-
run: ./gradlew build test jacocoTestReport sonarqube --refresh-dependencies --no-daemon --continue
32-
build_pull_request:
33-
if: github.event_name != 'release' && endsWith(github.REF, '/merge') == true
34-
runs-on: ubuntu-latest
35-
steps:
36-
- uses: actions/checkout@v2
37-
with:
38-
fetch-depth: 0
39-
- name: Set up JDK 11
40-
uses: actions/setup-java@v1
41-
with:
42-
java-version: 11
43-
- name: Grant execute permission for gradlew
44-
run: chmod +x gradlew
45-
- name: Execute build test and jacocoTestReport
34+
run: ./gradlew build test jacocoTestReport sonarqube --refresh-dependencies --no-daemon --continue --stacktrace
35+
- name: Execute build test jacocoTestReport and sonar analysis for pull request
36+
if: endsWith(github.REF, '/merge') == true
4637
env:
4738
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4839
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -52,9 +43,6 @@ jobs:
5243
-Dsonar.pullrequest.base=${{ github.BASE_REF }}
5344
-Dsonar.pullrequest.github.repository=${{ github.repository }}
5445
--refresh-dependencies --no-daemon --continue --stacktrace
55-
# run: ./gradlew test jacocoTestReport && cp build/reports/jacoco/report.xml jacoco.xml || echo "Code coverage failed"
56-
# - name: Push codeCoverage to Codecov
57-
# run: bash <(curl -s https://codecov.io/bash)
5846

5947
release:
6048
if: github.event_name == 'release'

0 commit comments

Comments
 (0)