Skip to content

Commit 51aae94

Browse files
committed
create new pull request job
1 parent 319e697 commit 51aae94

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,46 @@ on:
1414

1515
jobs:
1616
build:
17-
if: github.event_name != 'release'
17+
if: github.event_name != 'release' && endsWith(github.ref, '/master') == true
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v2
21-
- name: Set up JDK 8
21+
- name: Set up JDK 11
2222
uses: actions/setup-java@v1
2323
with:
24-
java-version: 8
24+
java-version: 11
2525
- name: Grant execute permission for gradlew
2626
run: chmod +x gradlew
2727
- name: Execute build test and jacocoTestReport
28-
run: ./gradlew build test jacocoTestReport --refresh-dependencies --no-daemon --continue
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
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+
ref: ${{ github.HEAD_REF }}
39+
- name: Retrieve entire repository history
40+
run: git fetch --prune --unshallow
2941
- name: Set up JDK 11
3042
uses: actions/setup-java@v1
3143
with:
3244
java-version: 11
33-
- name: Extract branch name
34-
shell: bash
35-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
36-
id: extract_branch
37-
- name: Run Sonar analysis
45+
- name: Grant execute permission for gradlew
46+
run: chmod +x gradlew
47+
- name: Execute build test and jacocoTestReport
3848
env:
39-
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
4049
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
run: ./gradlew sonarqube -Dsonar.branch=${{ steps.extract_branch.outputs.branch }}
50+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
51+
run: ./gradlew build test jacocoTestReport sonarqube
52+
-Dsonar.pullrequest.key=${{ github.event.number }}
53+
-Dsonar.pullrequest.branch=${{ github.HEAD_REF }}
54+
-Dsonar.pullrequest.base=${{ github.BASE_REF }}
55+
-Dsonar.pullrequest.github.repository=${{ github.repository }}
56+
--refresh-dependencies --no-daemon --continue
4257
# run: ./gradlew test jacocoTestReport && cp build/reports/jacoco/report.xml jacoco.xml || echo "Code coverage failed"
4358
# - name: Push codeCoverage to Codecov
4459
# run: bash <(curl -s https://codecov.io/bash)

0 commit comments

Comments
 (0)