Skip to content

Commit

Permalink
Update CI actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrutishauser committed Aug 7, 2021
1 parent 8235d89 commit 8592765
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ on:
pull_request:
branches:
- master
pull_request_target:
types:
- labeled
branches:
- master
release:
types:
- published

jobs:
build:
Expand All @@ -18,8 +26,24 @@ jobs:
java:
- 1.8
- 11
event:
- ${{ github.event_name }}
exclude:
- event: pull_request_target
java: 1.8
steps:
- uses: actions/checkout@v2
if: ${{ github.event_name != 'pull_request_target' }}
with:
fetch-depth: 0
persist-credentials: ${{ !startsWith(github.event_name, 'pull_request') }}
- uses: actions/checkout@v2
if: ${{ github.event_name == 'pull_request_target' }}
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
Expand All @@ -28,34 +52,50 @@ jobs:
run: >
git config --global user.email "[email protected]" &&
git config --global user.name "GitHub Actions"
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-${{ matrix.java }} ${{ runner.os }}-m2
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Build with Maven
run: mvn -B -V -e clean verify
- name: Unittest Coverage
if: ${{ matrix.java == '11' }}
if: ${{ matrix.java == '11' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report &&
bash <(curl -s https://codecov.io/bash) -c -F unittests
- name: Integrationstest Coverage
if: ${{ matrix.java == '11' }}
if: ${{ matrix.java == '11' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report-integration &&
bash <(curl -s https://codecov.io/bash) -c -F integration
- name: Sonar Report
if: ${{ matrix.java == '11' }}
if: ${{ matrix.java == '11' && (!startsWith(github.event_name, 'pull_request') || !github.event.pull_request.head.repo.fork || contains(github.event.pull_request.labels.*.name, 'sonar')) }}
run: >
git fetch --unshallow &&
mvn -B -e jacoco:report jacoco:report-integration sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=jonasrutishauser-github -Dsonar.login=$SONAR_TOKEN
if [ "$GITHUB_EVENT_NAME" == "pull_request_target" ];
then
export GITHUB_EVENT_NAME=pull_request;
export GITHUB_REF=refs/pull/$GITHUB_PULL_REQUEST/merge;
fi &&
mvn -B -e jacoco:report jacoco:report-integration sonar:sonar -Dsonar.organization=jonasrutishauser-github
env:
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_TOKEN: ${{ github.token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
- name: Deploy Site
if: ${{ matrix.java == '1.8' }}
if: ${{ matrix.java == '1.8' && github.event_name != 'release' && !startsWith(github.event_name, 'pull_request') }}
run: mvn -B -e site-deploy
env:
GITHUB_TOKEN: ${{ github.token }}
update-pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'sonar') }}
steps:
- name: Remove Sonar Label
uses: peter-murray/remove-labels-action@v1
with:
labels: sonar

0 comments on commit 8592765

Please sign in to comment.