diff --git a/.github/workflows/gradle-build-metadata.yml b/.github/workflows/gradle-build-metadata.yml new file mode 100644 index 0000000..73364ff --- /dev/null +++ b/.github/workflows/gradle-build-metadata.yml @@ -0,0 +1,123 @@ +name: Build Metadata + +on: + workflow_call: + inputs: + gradle-version: + description: Version returned from get-gradle-version workflow. + required: true + type: string + + outputs: + artifact-version: + description: Final artifact version. + value: ${{ jobs.metadata.outputs.artifact-version }} + docker-registry: + description: Docker Hub organization. + value: ${{ jobs.metadata.outputs.docker-registry }} + is-release: + description: Whether this is a release build. + value: ${{ jobs.metadata.outputs.is-release }} + is-main-branch: + description: Whether this build is running on the default branch. + value: ${{ jobs.metadata.outputs.is-main-branch }} + do-docker-push: + description: Whether Docker images should be pushed. + value: ${{ jobs.metadata.outputs.do-docker-push }} + repo-name: + description: Name of the GitHub Repository. + value: ${{ jobs.metadata.outputs.repo-name}} + repo-description: + description: Description of the GitHub Repository. + value: ${{ jobs.metadata.outputs.repo-description }} + +jobs: + metadata: + name: Generate Build Metadata + runs-on: ubuntu-latest + timeout-minutes: 10 + + outputs: + artifact-version: ${{ steps.metadata.outputs.artifact-version }} + docker-registry: ${{ steps.metadata.outputs.docker-registry }} + is-release: ${{ steps.metadata.outputs.is-release }} + is-main-branch: ${{ steps.metadata.outputs.is-main-branch }} + do-docker-push: ${{ steps.metadata.outputs.do-docker-push }} + repo-name: ${{ steps.metadata.outputs.repo-name }} + repo-description: ${{ steps.metadata.outputs.repo-description }} + + steps: + - name: Generate metadata + id: metadata + shell: bash + env: + GRADLE_VERSION: ${{ inputs.gradle-version }} + RUN_NUMBER: ${{ github.run_number }} + REF_TYPE: ${{ github.ref_type }} + REF_NAME: ${{ github.ref_name }} + EVENT_NAME: ${{ github.event_name }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + REPO_DESC: ${{ github.event.repository.description }} + run: | + BASE_NUMBER=2000 + BUILD_NUMBER=$(( BASE_NUMBER + RUN_NUMBER )) + echo "Gradle version: ${GRADLE_VERSION}" + echo "Git ref: ${REF_NAME} (${REF_TYPE})" + + if [[ "${REF_TYPE}" == "tag" ]]; then + TAG_VERSION="${REF_NAME#v}" + if [[ "${TAG_VERSION}" != "${GRADLE_VERSION}" ]]; then + echo "ERROR: Git tag '${REF_NAME}' does not match project version '${GRADLE_VERSION} from gradle.properties." + exit 1 + fi + ARTIFACT_VERSION="${GRADLE_VERSION}" + IS_RELEASE=true + DOCKER_REGISTRY="folioorg" + elif [[ "${GRADLE_VERSION}" == *"-SNAPSHOT" ]]; then + ARTIFACT_VERSION="${GRADLE_VERSION}.${BUILD_NUMBER}" + IS_RELEASE=false + DOCKER_REGISTRY="folioci" + else + ARTIFACT_VERSION="${GRADLE_VERSION}" + IS_RELEASE=false + DOCKER_REGISTRY="folioci" + fi + + if [[ "${REF_NAME}" == "${DEFAULT_BRANCH}" ]]; then + IS_MAIN_BRANCH=true + else + IS_MAIN_BRANCH=false + fi + + if [[ "${EVENT_NAME}" == "pull_request" ]]; then + DO_DOCKER_PUSH=false + elif [[ "${IS_RELEASE}" == "true" ]]; then + DO_DOCKER_PUSH=true + elif [[ "${GRADLE_VERSION}" == *"-SNAPSHOT" && "${IS_MAIN_BRANCH}" == "true" ]]; then + DO_DOCKER_PUSH=true + else + DO_DOCKER_PUSH=false + fi + + { + echo "artifact-version=${ARTIFACT_VERSION}" + echo "docker-registry=${DOCKER_REGISTRY}" + echo "is-release=${IS_RELEASE}" + echo "is-main-branch=${IS_MAIN_BRANCH}" + echo "do-docker-push=${DO_DOCKER_PUSH}" + echo "repo-name=${GITHUB_REPOSITORY##*/}" + echo "repo-description=${REPO_DESC}" + } >> "$GITHUB_OUTPUT" + + { + echo "### Build Metadata" + echo "" + echo "| Property | Value |" + echo "|----------|-------|" + echo "| Artifact Version | ${ARTIFACT_VERSION} |" + echo "| Docker Registry | ${DOCKER_REGISTRY} |" + echo "| Release Build | ${IS_RELEASE} |" + echo "| Main Branch | ${IS_MAIN_BRANCH} |" + echo "| Docker Push | ${DO_DOCKER_PUSH} |" + echo "| Git Ref | ${REF_NAME} (${REF_TYPE}) |" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml new file mode 100644 index 0000000..aecdb12 --- /dev/null +++ b/.github/workflows/gradle-build.yml @@ -0,0 +1,69 @@ +name: Gradle Build + +on: + workflow_call: + inputs: + gradle-directory: + description: Directory containing the Gradle project. + required: true + type: string + java-version: + description: Java version. + required: true + type: string + build-command: + description: Gradle command. + required: false + type: string + default: "assemble" + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + defaults: + run: + shell: bash + working-directory: ${{ inputs.gradle-directory }} + + steps: + - name: Checkout source + uses: actions/checkout@v6 + with: + fetch-depth: 1 + submodules: recursive + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v6 + + - name: Setup Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Build Project + run: | + ./gradlew \ + ${{ inputs.build-command }} \ + --console plain \ + --no-daemon + + - name: Upload application JAR + uses: actions/upload-artifact@v7 + with: + name: built-jars + path: | + ${{ inputs.gradle-directory }}/build/libs/*.jar + + - name: Upload ModuleDescriptor + uses: actions/upload-artifact@v7 + with: + name: ModuleDescriptor.json + path: | + ${{ inputs.gradle-directory }}/build/resources/main/okapi/ModuleDescriptor.json diff --git a/.github/workflows/gradle-dependency-submission.yml b/.github/workflows/gradle-dependency-submission.yml new file mode 100644 index 0000000..e456c81 --- /dev/null +++ b/.github/workflows/gradle-dependency-submission.yml @@ -0,0 +1,48 @@ +name: Dependency Submission + +on: + workflow_call: + inputs: + gradle-directory: + description: Directory containing the Gradle project. + required: true + type: string + java-version: + description: Java version. + required: true + type: string + +jobs: + dependency-submission: + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: write + defaults: + run: + shell: bash + working-directory: ${{ inputs.gradle-directory }} + + steps: + - name: Checkout source + uses: actions/checkout@v6 + with: + fetch-depth: 1 + submodules: recursive + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v6 + + - name: Setup Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: ${{ inputs.java-version }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Submit Dependency Graph + uses: gradle/actions/dependency-submission@v6 + with: + build-root-directory: ${{ inputs.gradle-directory }} diff --git a/.github/workflows/gradle-docker-publish.yml b/.github/workflows/gradle-docker-publish.yml new file mode 100644 index 0000000..b2dad9a --- /dev/null +++ b/.github/workflows/gradle-docker-publish.yml @@ -0,0 +1,166 @@ +name: Gradle Docker Build and Publish + +on: + workflow_call: + inputs: + artifact-id: + description: Docker image name. + required: true + type: string + artifact-version: + description: Artifact version. + required: true + type: string + docker-registry: + description: Docker registry/organization. + required: true + type: string + docker-health-command: + description: Docker health check command. + required: false + type: string + default: '' + do-docker-push: + description: Whether to publish the Docker image. + required: true + type: boolean + docker-label-documentation: + description: Documentation URL for OCI label. + required: false + type: string + default: '' + secrets: + dockerhub-username: + required: true + dockerhub-token: + required: true + +jobs: + docker: + name: Docker Build${{ inputs.do-docker-push && ' and Publish' || '' }} + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + + steps: + # Checkout + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + # Download Gradle build artifacts + - name: Download built JARs + uses: actions/download-artifact@v8 + with: + name: built-jars + path: . + + - name: Restore Gradle build directory + run: | + mkdir -p service/build/libs + mv -- *.jar service/build/libs/ + + # Notify whether publishing Docker image + - name: Notify whether doing Docker push + run: | + if ${{ inputs.do-docker-push }}; then + echo "Will build and publish Docker image." | tee -a "$GITHUB_STEP_SUMMARY" + else + echo "Will build Docker image only (publish=false)." | tee -a "$GITHUB_STEP_SUMMARY" + fi + + # Login to Docker Hub + - name: Login to Docker Hub + if: inputs.do-docker-push + uses: docker/login-action@v4 + with: + username: ${{ secrets.dockerhub-username }} + password: ${{ secrets.dockerhub-token }} + + # Extract Docker metadata + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v6 + with: + images: ${{ inputs.docker-registry }}/${{ inputs.artifact-id }} + + labels: | + org.opencontainers.image.title=FOLIO ${{ inputs.artifact-id }} + org.opencontainers.image.documentation=${{ inputs.docker-label-documentation }} + org.opencontainers.image.vendor=The Open Library Foundation + org.opencontainers.image.licenses=Apache-2.0 + org.opencontainers.image.version=${{ inputs.artifact-version }} + + tags: | + type=raw,value=latest + type=raw,value=${{ inputs.artifact-version }} + + # Prepare Docker test image + - name: Prepare Docker test tag + id: prepare-docker-test-tag + run: | + echo "docker-test-tag=folioci/${{ inputs.artifact-id }}:test" >> "$GITHUB_OUTPUT" + + if ${{ inputs.docker-health-command != '' }}; then + echo "docker-health-command='${{ inputs.docker-health-command }}'" | tee -a "$GITHUB_STEP_SUMMARY" + else + echo "> [!WARNING]" >> "$GITHUB_STEP_SUMMARY" + { + echo "> Not doing docker health check. The inputs.docker-health-command is not declared." + echo "> The docker image might not be reliable." + echo "> Refer to [documentation](https://github.com/folio-org/.github/blob/master/README-maven.md#configuration-docker-health-command)." + } | tee -a "$GITHUB_STEP_SUMMARY" + fi + + # Build and validate Docker image + - name: Build and test Docker image + if: inputs.docker-health-command != '' + run: | + echo "Building test image..." + docker build \ + --pull=true \ + --no-cache=true \ + -t "${{ steps.prepare-docker-test-tag.outputs.docker-test-tag }}" . + + echo "Starting test container..." + + docker run \ + --detach \ + --health-timeout=2s \ + --health-retries=2 \ + --cidfile docker_test.cid \ + --health-cmd='${{ inputs.docker-health-command }}' \ + "${{ steps.prepare-docker-test-tag.outputs.docker-test-tag }}" + + cid="$(cat docker_test.cid)" + echo "Waiting for container health..." + max_startup_wait=60 + for ((i=1;i<=max_startup_wait;i++)); do + health=$(docker inspect "$cid" | jq -r '.[0].State.Health.Status') + echo "Current status: ${health}" + if [[ "${health}" == "starting" ]]; then + sleep 1 + else + break + fi + done + if [[ "${health}" != "healthy" ]]; then + echo "Container health check failed." + echo "========== Docker Logs ==========" + docker logs "$cid" || true + echo "========== Docker Inspect ==========" + docker inspect "$cid" || true + exit 1 + fi + echo "Container health check passed." + + # Build and optionally publish Docker image + - name: Build${{ inputs.do-docker-push && ' and Publish' || '' }} Docker image + uses: docker/build-push-action@v7 + with: + context: . + push: ${{ inputs.do-docker-push }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/gradle-get-version-number.yml b/.github/workflows/gradle-get-version-number.yml new file mode 100644 index 0000000..01ebe71 --- /dev/null +++ b/.github/workflows/gradle-get-version-number.yml @@ -0,0 +1,44 @@ +name: Get Gradle Version + +on: + workflow_call: + inputs: + gradle-directory: + description: Directory containing the Gradle project. + required: true + type: string + + outputs: + gradle-version: + description: Version reported by Gradle. + value: ${{ jobs.version.outputs.gradle-version }} + +jobs: + version: + name: Determine Gradle Version + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + gradle-version: ${{ steps.version.outputs.gradle-version }} + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v6 + + - name: Read Gradle version + id: version + working-directory: ${{ inputs.gradle-directory }} + shell: bash + run: | + VERSION="$(awk -F= '/^appVersion=/ {print $2}' gradle.properties)" + if [[ -z "$VERSION" ]]; then + echo "Unable to determine Gradle project version." + exit 1 + fi + echo "Detected Gradle version: $VERSION" + echo "gradle-version=$VERSION" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/gradle-module-descriptor-publish.yml b/.github/workflows/gradle-module-descriptor-publish.yml new file mode 100644 index 0000000..f46c4f6 --- /dev/null +++ b/.github/workflows/gradle-module-descriptor-publish.yml @@ -0,0 +1,46 @@ +name: Publish ModuleDescriptor + +on: + workflow_call: + inputs: + module-descriptor-registry: + description: URL of the ModuleDescriptor registry. + required: true + type: string + secrets: + registry-username: + required: true + registry-password: + required: true + +jobs: + publish: + name: Publish ModuleDescriptor + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + # Download ModuleDescriptor produced by gradle-build.yml + - name: Download ModuleDescriptor + uses: actions/download-artifact@v8 + with: + name: ModuleDescriptor.json + + # Publish ModuleDescriptor + - name: Publish ModuleDescriptor + uses: fjogeleit/http-request-action@v2 + with: + url: ${{ inputs.module-descriptor-registry }}/_/proxy/modules + method: POST + contentType: application/json; charset=utf-8 + customHeaders: > + { + "Accept": "application/json; charset=utf-8" + } + timeout: 10000 + retry: 10 + retryWait: 21000 + file: ModuleDescriptor.json + username: ${{ secrets.registry-username }} + password: ${{ secrets.registry-password }} diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..5e3b045 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,136 @@ +name: Gradle Backend Module + +on: + workflow_call: + inputs: + artifact-id: + description: Artifact/module name (e.g. mod-agreements). + required: true + type: string + gradle-directory: + description: Directory containing the Gradle project. + required: false + default: service + type: string + publish-module-descriptor: + description: Publish module descriptor? + required: false + type: boolean + default: true + module-descriptor-registry: + description: Okapi ModuleDescriptor registry URL. + required: false + default: https://folio-registry.dev.folio.org + type: string + docker-health-command: + description: Docker health check command. + required: false + default: "" + type: string + docker-label-documentation: + description: OCI documentation label. + required: false + default: "" + type: string + java-version: + description: Java version. + required: false + type: string + default: "17" + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true + FOLIO_REGISTRY_USERNAME: + required: true + FOLIO_REGISTRY_PASSWORD: + required: true + +# Determine Gradle version +jobs: + get-gradle-version: + name: Determine Gradle Version + uses: ./.github/workflows/gradle-get-version-number.yml + with: + gradle-directory: ${{ inputs.gradle-directory }} + +# Build metadata + metadata: + name: Build Metadata + needs: + - get-gradle-version + uses: ./.github/workflows/gradle-build-metadata.yml + with: + gradle-version: ${{ needs.get-gradle-version.outputs.gradle-version }} + +# Build application + gradle-build: + name: Gradle Build + needs: + - metadata + uses: ./.github/workflows/gradle-build.yml + with: + gradle-directory: ${{ inputs.gradle-directory }} + java-version: ${{ inputs.java-version }} + +# Dependency submission + dependency-submission: + name: Dependency Submission + needs: + - gradle-build + uses: ./.github/workflows/gradle-dependency-submission.yml + with: + gradle-directory: ${{ inputs.gradle-directory }} + java-version: ${{ inputs.java-version }} + +# Docker build + docker-build: + name: Docker Build + needs: + - metadata + - gradle-build + uses: ./.github/workflows/gradle-docker-publish.yml + with: + artifact-id: ${{ inputs.artifact-id }} + artifact-version: ${{ needs.metadata.outputs.artifact-version }} + docker-registry: ${{ needs.metadata.outputs.docker-registry }} + docker-health-command: ${{ inputs.docker-health-command }} + docker-label-documentation: ${{ inputs.docker-label-documentation }} + do-docker-push: ${{ fromJSON(needs.metadata.outputs.do-docker-push) }} + secrets: + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN}} + +# Docker image description + docker-description: + name: Publish image description + needs: + - metadata + - docker-build + if: | + !cancelled() && needs.metadata.outputs.do-docker-push == 'true' + uses: ./.github/workflows/docker-description.yml + with: + artifact-id: ${{ inputs.artifact-id }} + docker-registry: ${{ needs.metadata.outputs.docker-registry }} + repo-description: ${{ needs.metadata.outputs.repo-description }} + publish-module-descriptor: ${{ inputs.publish-module-descriptor }} + secrets: + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} + +# Publish ModuleDescriptor + publish-module-descriptor: + name: Publish ModuleDescriptor + if: | + !cancelled() && inputs.publish-module-descriptor && needs.metadata.outputs.do-docker-push == 'true' + needs: + - metadata + - docker-build + uses: ./.github/workflows/gradle-module-descriptor-publish.yml + with: + module-descriptor-registry: ${{ inputs.module-descriptor-registry }} + secrets: + registry-username: ${{ secrets.FOLIO_REGISTRY_USERNAME }} + registry-password: ${{ secrets.FOLIO_REGISTRY_PASSWORD }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e338b0..94a0ff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## IN PROGRESS * FOLIO-4555 Double-quote variables - in #164, #166 +* FOLIO-4554 Create Reusable workflows for Gradle based modules - in #165 * (Add more progress summary items here.) ## [1.16.3](https://github.com/folio-org/.github/tree/v1.16.3) (2026-07-14) diff --git a/README-gradle.md b/README-gradle.md new file mode 100644 index 0000000..c1b8034 --- /dev/null +++ b/README-gradle.md @@ -0,0 +1,207 @@ +# Centralised GitHub Workflows for Gradle + + +* [Introduction](#introduction) +* [Usage](#usage) +* [Configuration](#configuration) + * [Configuration: artifact-id](#configuration-artifact-id) + * [Configuration: gradle-directory](#configuration-gradle-directory) + * [Configuration: module-descriptor-registry](#configuration-module-descriptor-registry) + * [Configuration: java-version](#configuration-java-version) + * [Configuration: publish-module-descriptor](#configuration-publish-module-descriptor) + * [Configuration: docker-health-command](#configuration-docker-health-command) + * [Configuration: docker-label-documentation](#configuration-docker-label-documentation) +* [Docker image metadata](#docker-image-metadata) +* [Install the caller Workflow](#install-the-caller-workflow) + + +## Introduction + +The Workflows in this repository named `gradle*.yml` are for building Gradle-based back-end modules. +Docker images are published to FOLIO Docker Hub. +ModuleDescriptors are published to the FOLIO Registry. + +Refer to example build system and workflows at https://github.com/folio-org/mod-agreements + +## Usage + +Create a `.github/workflows` directory in the root of the module repository, and add a file named `gradle.yml` with the following content. + +If there is already a workflow named gradle.yml for verifying basic Gradle builds, then rename that file. +It will ease management to have the same filename at every repository. + +Follow [Install the caller Workflow](#install-the-caller-workflow) section below to install the initial workflow. + +After the first Actions run, do not rename the filename of this caller workflow, as that will reset the GitHub run number and so wreck the sequential order of the ModuleDescriptor identifiers. + + +```yaml +# https://github.com/folio-org/.github/blob/master/README-gradle.md + +name: Gradle Central Workflow + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + gradle: + uses: folio-org/.github/.github/workflows/gradle.yml@v1 + # Only handle push events from the main branch or tags, to decrease PR noise + if: github.ref_name == github.event.repository.default_branch || github.event_name != 'push' || github.ref_type == 'tag' + secrets: inherit + with: + artifact-id: mod-agreements + docker-label-documentation: https://github.com/folio-org/mod-agreements/tree/master/docs +``` + +## Configuration + +If there is a need to over-ride defaults, then add configuration variables to the single "with:" section of the module gradle.yml Workflow. + +Add the section at the end of the Workflow immediately after the "secrets" item. +For example: + +```yaml + # ... + secrets: inherit + with: + java-version: '17' + # Add configuration variables here if needed. +``` +### Configuration: artifact-id + +This is the name of the module being built e.g mod-agreements. It's required as it's the name of the build artifact and docker image that would be built and pushed. + +```yaml + with: + artifact-id: mod-agreements +``` + +### Configuration: gradle-directory + +The directory containing the Gradle project to be built. + +Optional. Default = service + +```yaml + with: + gradle-directory: service +``` + +### Configuration: module-descriptor-registry + +Okapi Module descriptor registry URL + +Optional. Default = 'https://folio-registry.dev.folio.org' + +```yaml + with: + module-descriptor-registry: 'https://folio-registry.dev.folio.org' +``` + +### Configuration: java-version + +Optional. Default = '17' + +```yaml + with: + java-version: '17' +``` + +### Configuration: publish-module-descriptor + +Some Gradle-based projects do not have a ModuleDescriptor. + +Optional. Default = true + +```yaml + with: + publish-module-descriptor: false +``` + +### Configuration: docker-health-command + +If this variable is provided, then the Docker Health Check will be run prior to the final building of the image. If it fails, then no Docker image is built, and a ModuleDescriptor will not be published. + + +Note that the workflow will utilise this variable if provided, but does not enforce it. +The status will be reported to the workflow "Summary". + +Optional. Default = None + +```yaml + with: + docker-health-command: 'wget --no-verbose --tries=1 --spider http://localhost:8081/admin/health || exit 1' +``` + +### Configuration: docker-label-documentation + +If not provided then the "org.opencontainers.image.documentation" label of the Docker image will be empty. + +Optional. Default = None + +```yaml + with: + docker-label-documentation: 'https://.../documentation.md' +``` + +## Docker image metadata + +The docker image will have various labels automatically applied. + +Note: If the "org.opencontainers.image.description" label of the generated image is empty, then that is because the module's GitHub repository is missing the "About" description in the top-right corner of its GitHub front page. +See advice at [Create a new FOLIO module and do initial setup](https://dev.folio.org/guidelines/create-new-repo/), +and bear in mind that Docker Hub imposes a [content length limit](https://github.com/peter-evans/dockerhub-description#content-limits) of 100 bytes for that short-description, so it will be truncated at that. + +See also the [Configuration: docker-label-documentation](#configuration-docker-label-documentation) variable. + +## Install the caller Workflow + +Create a new branch at the module repository. + +Create a file at `.github/workflows/gradle.yml` as explained at the [Usage](#usage) section. + +Add other [Configuration](#configuration) variables to suit the needs of the module, e.g. `docker-health-command` variable. +Align properties with the old Jenkinsfile (noting the defaults shown in the [Configuration](#configuration) section). + +Do `git mv Jenkinsfile Jenkinsfile-disabled` (so that it can be restored quickly if needed, and still be able to review its properties). + +Commit and push. + +(If it is desired to do a branch run prior to raising the pull-request, then "dispatch" the workflow on that branch. +However the line 12 "if:" will need to be temporarily commented-out for one run, because the workflow does not yet exist on mainline branch.) + +Raise the pull-request, and review the run results. + +The merge will be denied. The "check" for the old Jenkins "pr-merge" will fail. + +Edit "Branch protection" to delete that check, and add a new `GitHub Actions` check: + +For most Docker-providing repositories the check will be: \ +`gradle / Docker Build / Docker Build` + +For non-Docker repositories the check will be: \ +`gradle / Gradle Build / build` + + +If assistance is needed with "Branch protection" then [contact](https://dev.folio.org/faqs/how-to-raise-devops-ticket/#general-folio-devops) FOLIO DevOps and advise the checks that you need. + +Wait until after the next "Platform build" to give some time if things go amiss. +https://dev.folio.org/guides/automation/#platform-hourly-build (finishes approx 53m past) +https://github.com/folio-org/platform-complete/commits/snapshot/ + +Merge and watch the mainline branch run. + +Review the results for the Docker image and ModuleDescriptor. The identifier for all modules will use base number 2000 plus the sequential workflow run_number (e.g. 2002 for the second run). + +Visit the following resources (adjusted for the relevant repository name): +* https://hub.docker.com/r/folioci/mod-agreements/tags +* https://hub.docker.com/r/folioci/mod-agreements (for new generated description) +* https://folio-registry.dev.folio.org/_/proxy/modules?filter=mod-agreements&latest=1 +* https://folio-registry.dev.folio.org/_/proxy/modules?filter=mod-agreements&latest=1&full=true + +Await success of the subsequent "Platform hourly build" and see snapshot branch updated. + +If there is a need to quickly revert to Jenkins-based build, then [delete](https://github.com/folio-org/mod-settings/blob/master/.github/workflows/delete-test-md.yml) the published ModuleDescriptor (with great care), re-configure the branch protection checks, restore the Jenkinsfile. diff --git a/README.md b/README.md index 85327b6..6dfb737 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Refer to the various types of centralized workflows, including their setup and c * [README-docker.md](README-docker.md) -- for repositories that only have a Dockerfile. * [README-go.md](README-go.md) and [README-go-lint.md](README-go-lint.md) -- for Go-based back-end repositories. * [README-maven.md](README-maven.md) -- for Maven-based back-end repositories. +* [README-gradle.md](README-gradle.md) -- for Gradle-based back-end repositories. ## Development