name: Code Coverage

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - '*'

jobs:
  publish-code-coverage:
    if: ${{ !contains(github.event.head_commit.message, 'coverage skip') }}
    runs-on: ubuntu-latest
    env:
      JDK_VERSION:  ${{ matrix.jdk }}
      GRADLE_OPTS: -Dorg.gradle.daemon=false
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2

      - name: Setup Java
        uses: actions/setup-java@v1
        with:
          java-version: 11

      - name: Generate Coverage Report
        run: ./gradlew jacocoTestReport -Dorg.gradle.caching=false

      - name: Publish Coverage
        if: success()
        run: bash <(curl -s https://codecov.io/bash)
        shell: bash
