2022-12-14 15:12:23 +00:00
|
|
|
name: Maven Cache
|
|
|
|
description: Caches Maven artifacts
|
|
|
|
|
2023-03-07 10:44:49 +00:00
|
|
|
inputs:
|
|
|
|
create-cache-if-it-doesnt-exist:
|
|
|
|
description: >
|
|
|
|
Only those callers which fill the cache with the right contents should set this to true to avoid creating a cache
|
|
|
|
which contains too few or too many entries.
|
|
|
|
required: false
|
|
|
|
default: false
|
|
|
|
|
2022-12-14 15:12:23 +00:00
|
|
|
runs:
|
|
|
|
using: composite
|
|
|
|
steps:
|
|
|
|
- id: weekly-cache-key
|
|
|
|
name: Key for weekly rotation of cache
|
|
|
|
shell: bash
|
|
|
|
run: echo "key=mvn-`date -u "+%Y-%U"`" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- id: cache-maven-repository
|
|
|
|
name: Maven cache
|
2024-03-22 07:57:41 +00:00
|
|
|
uses: actions/cache@v4
|
2023-03-07 10:44:49 +00:00
|
|
|
if: inputs.create-cache-if-it-doesnt-exist == 'true'
|
2022-12-14 15:12:23 +00:00
|
|
|
with:
|
2023-03-07 10:44:49 +00:00
|
|
|
# Two asterisks are needed to make the follow-up exclusion work
|
|
|
|
# see https://github.com/actions/toolkit/issues/713 for the upstream issue
|
|
|
|
path: |
|
|
|
|
~/.m2/repository/*/*
|
|
|
|
!~/.m2/repository/org/keycloak
|
2022-12-14 15:12:23 +00:00
|
|
|
key: ${{ steps.weekly-cache-key.outputs.key }}
|
2024-08-01 12:30:58 +00:00
|
|
|
# Enable cross-os archive use the cache on both Linux and Windows
|
|
|
|
enableCrossOsArchive: true
|
|
|
|
|
|
|
|
- shell: powershell
|
|
|
|
name: Link the cached Maven repository to the OS-dependent location
|
|
|
|
if: inputs.create-cache-if-it-doesnt-exist == 'false' && runner.os == 'Windows'
|
|
|
|
# The cache restore in the next step uses the relative path which was valid on Linux and that is part of the archive it downloads.
|
|
|
|
# You'll see that path when you enable debugging for the GitHub workflow on Windows.
|
|
|
|
# On Windows, the .m2 folder is in different location, so move all the contents to the right folder here.
|
|
|
|
# Also, not using the C: drive will speed up the build, see https://github.com/actions/runner-images/issues/8755
|
|
|
|
run: |
|
|
|
|
mkdir -p ../../../.m2/repository
|
|
|
|
cmd /c mklink /d $HOME\.m2\repository D:\.m2\repository
|
2022-12-14 15:12:23 +00:00
|
|
|
|
2023-03-07 10:44:49 +00:00
|
|
|
- id: restore-maven-repository
|
|
|
|
name: Maven cache
|
2024-03-22 07:57:41 +00:00
|
|
|
uses: actions/cache/restore@v4
|
2023-03-07 10:44:49 +00:00
|
|
|
if: inputs.create-cache-if-it-doesnt-exist == 'false'
|
|
|
|
with:
|
2024-08-01 12:30:58 +00:00
|
|
|
# This needs to repeat the same path pattern as above to find the matching cache
|
2023-03-07 10:44:49 +00:00
|
|
|
path: |
|
|
|
|
~/.m2/repository/*/*
|
|
|
|
!~/.m2/repository/org/keycloak
|
|
|
|
key: ${{ steps.weekly-cache-key.outputs.key }}
|
2024-10-17 06:06:45 +00:00
|
|
|
enableCrossOsArchive: true
|
|
|
|
|
|
|
|
- name: Get Node.js and PNPM versions
|
|
|
|
id: tooling-versions
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "node=$(mvn help:evaluate -Dexpression=node.version -q -DforceStdout | cut -c 2-)" >> $GITHUB_OUTPUT
|
|
|
|
echo "pnpm=$(mvn help:evaluate -Dexpression=pnpm.version -q -DforceStdout)" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
# Downloading Node.js often fails due to network issues, therefore we cache the artifacts downloaded by the frontend plugin.
|
|
|
|
- uses: actions/cache@v4
|
|
|
|
name: Cache Node.js related artifacts
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.m2/repository/com/github/eirslett/node
|
|
|
|
~/.m2/repository/com/github/eirslett/pnpm
|
|
|
|
key: ${{ runner.os }}-frontend-plugin-artifacts-${{ steps.tooling-versions.outputs.node }}-${{ steps.tooling-versions.outputs.pnpm }}
|