|
14 | 14 |
|
15 | 15 | jobs: |
16 | 16 | build: |
17 | | - if: github.event_name != 'release' |
| 17 | + if: github.event_name != 'release' && endsWith(github.ref, '/master') == true |
18 | 18 | runs-on: ubuntu-latest |
19 | 19 | steps: |
20 | 20 | - uses: actions/checkout@v2 |
21 | | - - name: Set up JDK 8 |
| 21 | + - name: Set up JDK 11 |
22 | 22 | uses: actions/setup-java@v1 |
23 | 23 | with: |
24 | | - java-version: 8 |
| 24 | + java-version: 11 |
25 | 25 | - name: Grant execute permission for gradlew |
26 | 26 | run: chmod +x gradlew |
27 | 27 | - 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 |
29 | 41 | - name: Set up JDK 11 |
30 | 42 | uses: actions/setup-java@v1 |
31 | 43 | with: |
32 | 44 | 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 |
38 | 48 | env: |
39 | | - SONAR_TOKEN: ${{secrets.SONAR_TOKEN}} |
40 | 49 | 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 |
42 | 57 | # run: ./gradlew test jacocoTestReport && cp build/reports/jacoco/report.xml jacoco.xml || echo "Code coverage failed" |
43 | 58 | # - name: Push codeCoverage to Codecov |
44 | 59 | # run: bash <(curl -s https://codecov.io/bash) |
|
0 commit comments