# Here lie dragons!
#
# Note that there is no artifact step in this script. We do not want Paperclip
# jars to be built for every push & PR; our CI handles pushes to branches, while
# PRs can themselves link to Paperclip jars if it is necessary. Official such
# PRs will take use of testing builds.

name: Build Paper
on: [push, pull_request]

jobs:
    build:
        # Only run on PRs if the source branch is on someone else's repo
        if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
        runs-on: ubuntu-latest
        strategy:
            matrix:
                java: [17]
            fail-fast: true
        steps:
            - uses: actions/checkout@v2.4.0
            - name: JDK ${{ matrix.java }}
              uses: actions/setup-java@v3.1.0
              with:
                  java-version: ${{ matrix.java }}
                  cache: 'gradle'
                  distribution: 'temurin'
            - name: Patch and build
              run: |
                  git config --global user.email "no-reply@github.com"
                  git config --global user.name "Github Actions"
                  ./gradlew applyPatches --stacktrace
                  ./gradlew build --stacktrace
