name: Build
on:
  push:
    branches: [ develop, main, feat/* ]
  pull_request:
    branches: [ develop, main ]

jobs:
  build:
    strategy:
      matrix:
        jdk: [8, 11, 17]
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: postgres
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          # Maps tcp port 5432 on service container to the host
          - 5432:5432
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: gradle/wrapper-validation-action@v1
      - uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.jdk }}
      - uses: gradle/gradle-build-action@v2
        with:
          arguments: build --scan
        env:
          POSTGRES_HOST: localhost
          POSTGRES_PORT: 5432
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres

name: Build
on:
  push:
    branches: [ develop, main, feat/* ]
  pull_request:
    branches: [ develop, main ]

jobs:
  build:
    strategy:
      matrix:
        jdk: [8, 11, 17]
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: postgres
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          # Maps tcp port 5432 on service container to the host
          - 5432:5432
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: gradle/wrapper-validation-action@v1
      - uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.jdk }}
      - uses: gradle/gradle-build-action@v2
        with:
          arguments: build --scan
        env:
          POSTGRES_HOST: localhost
          POSTGRES_PORT: 5432
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
      - name: "Comment build scan url"
        uses: actions/github-script@v3
        if: github.event_name == 'pull_request' && failure()
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            github.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: '❌ ${{ github.workflow }} failed: ${{ steps.gradle.outputs.build-scan-url }}'
            })

Add build scan links for failed PRs
Add build scan links for failed PRs
