Update EEA Files #1371
This file contains hidden or 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
| # SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com) and contributors | |
| # SPDX-FileContributor: Sebastian Thomschke (https://sebthom.de), Vegard IT GmbH (https://vegardit.com) | |
| # SPDX-License-Identifier: EPL-2.0 | |
| # SPDX-ArtifactOfProjectHomePage: https://github.com/vegardit/no-npe | |
| # | |
| # https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax | |
| name: Update EEA Files | |
| on: # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows | |
| schedule: | |
| # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#schedule | |
| - cron: "0 5 * * *" # daily at 5 a.m. | |
| workflow_dispatch: | |
| # https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch | |
| inputs: | |
| extra-maven-args: | |
| description: "Additional command-line arguments to append to all Maven invocations" | |
| default: "" | |
| type: string | |
| library: | |
| description: "Name of the library to update (e.g. eea-gson-2). If left empty all libraries are updated." | |
| default: "" | |
| type: string | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| ########################################################### | |
| build: | |
| ########################################################### | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: "Show: GitHub context" | |
| env: | |
| GITHUB_CONTEXT: ${{ toJSON(github) }} | |
| run: echo $GITHUB_CONTEXT | |
| - name: "Show: environment variables" | |
| run: env | sort | |
| - name: Git Checkout | |
| uses: actions/checkout@v6 # https://github.com/actions/checkout | |
| - name: "Install: JDKs ☕" | |
| uses: sebthom/gha-shared/.github/actions/setup-java@v1 | |
| with: | |
| jdks: 11,17,21,25 | |
| - name: "Configure Maven JDK ☕" | |
| run: | | |
| set -euo pipefail | |
| JAVA_HOME="$JAVA25_HOME" | |
| if [[ "${RUNNER_OS:-}" == "Windows" ]]; then | |
| echo "${JAVA_HOME}\\bin" >>"$GITHUB_PATH" | |
| else | |
| echo "${JAVA_HOME}/bin" >>"$GITHUB_PATH" | |
| fi | |
| echo "JAVA_HOME=${JAVA_HOME}" >>"$GITHUB_ENV" | |
| - name: "Cache: Restore" | |
| id: cache-restore | |
| uses: actions/cache/restore@v5 | |
| with: | |
| # IMPORTANT: path must have exactly the same value as in the cache save step otherwise restore will fail with cache key not found | |
| path: | | |
| ~/.m2/bin | |
| ~/.m2/repository/* | |
| !~/.m2/repository/.cache | |
| !~/.m2/repository/.meta | |
| !~/.m2/repository/*SNAPSHOT* | |
| key: ubuntu-latest-mvn-repo-${{ hashFiles('**/pom.xml') }} | |
| - name: "Update EEA Files 🔨" | |
| id: eea_updates | |
| run: | | |
| set -euo pipefail | |
| bash .ci/update-eea-files.sh \ | |
| $( [[ -n "${{ inputs.library }}" ]] && echo '-pl "libs/${{ inputs.library }}" -am' || true ) \ | |
| ${{ inputs.extra-maven-args }} | |
| updates=$(git -C . ls-files -o -m -d --exclude-standard | head -n 50 || true) # "|| true" is to mitgate exit code 141 | |
| if [[ -z $updates ]]; then | |
| echo "updates=" >> "$GITHUB_OUTPUT" | |
| else | |
| # https://github.com/orgs/community/discussions/26288#discussioncomment-3876281 | |
| delimiter="$(openssl rand -hex 8)" | |
| echo "updates<<${delimiter}" >> "${GITHUB_OUTPUT}" | |
| echo "${updates}" >> "${GITHUB_OUTPUT}" | |
| echo "${delimiter}" >> "${GITHUB_OUTPUT}" | |
| fi | |
| - name: Create PR | |
| id: create-pr | |
| uses: peter-evans/create-pull-request@v8 # https://github.com/peter-evans/create-pull-request | |
| if: steps.eea_updates.outputs.updates | |
| with: | |
| title: "chore: Update ${{ inputs.library && format('{0} ', inputs.library) || '' }}EEA files" | |
| author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" | |
| committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" | |
| commit-message: "chore: Update EEA ${{ inputs.library && format('{0} ', inputs.library) || '' }}files" | |
| body: ${{ steps.eea_updates.outputs.updates }} | |
| add-paths: libs | |
| branch: ${{ inputs.library && format('eea_{0}_updates', inputs.library) || 'eea_updates' }} | |
| delete-branch: true |