build: cleanup and standardize docs build file (#52) #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI | |
on: | |
push: | |
branches: | |
- '[5-9]+.[0-9]+.x' | |
pull_request: | |
branches: | |
- '[5-9]+.[0-9]+.x' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8 | |
steps: | |
- name: "π₯ Checkout repository" | |
uses: actions/checkout@v4 | |
- name: "βοΈ Setup JDK" | |
uses: actions/setup-java@v4 | |
with: | |
distribution: liberica | |
java-version: 17 | |
- name: "π Setup Gradle" | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} | |
- name: "π¨ Build project" | |
id: build | |
env: | |
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} | |
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} | |
run: | |
./gradlew build | |
- name: Publish Test Report | |
if: steps.build.outcome == 'failure' | |
uses: scacap/action-surefire-report@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
publish: | |
if: github.event_name == 'push' | |
needs: [ 'build' ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: "π₯ Checkout repository" | |
uses: actions/checkout@v4 | |
- name: "βοΈ Setup JDK" | |
uses: actions/setup-java@v4 | |
with: | |
distribution: liberica | |
java-version: 17 | |
- name: "π Setup Gradle" | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} | |
- name: "π€ Publish Snapshot Artifacts" | |
id: publish | |
env: | |
MAVEN_PUBLISH_USERNAME: ${{ secrets.MAVEN_PUBLISH_USERNAME }} | |
MAVEN_PUBLISH_PASSWORD: ${{ secrets.MAVEN_PUBLISH_PASSWORD }} | |
MAVEN_PUBLISH_URL: ${{ secrets.MAVEN_PUBLISH_SNAPSHOT_URL }} | |
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} | |
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} | |
run: ./gradlew publish | |
docs: | |
if: github.event_name == 'push' | |
needs: publish | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
GIT_USER_NAME: grails-build | |
GIT_USER_EMAIL: grails-build@users.noreply.github.com | |
steps: | |
- name: "π₯ Checkout repository" | |
uses: actions/checkout@v4 | |
- name: "βοΈ Setup JDK" | |
uses: actions/setup-java@v4 | |
with: | |
distribution: liberica | |
java-version: 17 | |
- name: "π Setup Gradle" | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} | |
- name: "π Build Documentation" | |
run: ./gradlew docs:docs | |
- name: "π Publish to Github Pages" | |
id: docs | |
if: success() | |
uses: grails/github-pages-deploy-action@v2 | |
env: | |
SKIP_SNAPSHOT: ${{ contains(needs.publish.outputs.release_version, 'M') }} | |
TARGET_REPOSITORY: ${{ github.repository }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
BRANCH: gh-pages | |
FOLDER: docs/build/docs | |
DOC_FOLDER: gh-pages | |
COMMIT_EMAIL: ${{ env.GIT_USER_EMAIL }} | |
COMMIT_NAME: ${{ env.GIT_USER_NAME }} |