Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
9da1fd106c
ci(forgejo-actions): added missing cache key
All checks were successful
Build, test and publish the Quarkus libraries / build (push) Successful in 16m26s
2024-11-06 17:35:01 +01:00
571dbb4b6f
ci(forgejo-actions): implement cache of ~/.m2/repository 2024-11-06 17:35:01 +01:00

View file

@ -31,12 +31,49 @@ jobs:
}
}]
- name: Generate Maven Repository cache keys
id: cache-key
run: |
CURRENT_BRANCH="${{ gitea.base_ref || gitea.ref_name }}"
CURRENT_MONTH=$(/bin/date -u "+%Y-%m")
CURRENT_DAY=$(/bin/date -u "+%d")
ROOT_CACHE_KEY="m2-cache"
echo "m2-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITEA_OUTPUT
echo "m2-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITEA_OUTPUT
echo "m2-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITEA_OUTPUT
- name: Cache Maven Repository
id: cache-maven
uses: https://github.com/actions/cache@v4
with:
path: ~/.m2/repository
# A new cache will be stored daily. After that first store of the day, cache save actions will fail because the cache is immutable but it's not a problem.
# The whole cache is dropped monthly to prevent unlimited growth.
# The cache is per branch but in case we don't find a branch for a given branch, we will get a cache from another branch.
key: ${{ steps.cache-key.outputs.m2-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.m2-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.m2-monthly-cache-key }}-
- name: Restore Maven Repository
uses: https://github.com/actions/cache/restore@v4
with:
path: ~/.m2/repository
key: ${{ steps.cache-key.outputs.m2-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.m2-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.m2-monthly-cache-key }}-
- name: Make maven wrapper executable
run: chmod +x mvnw
- name: Populate the cache
run: |
./mvnw quarkus:go-offline
- name: Build and run tests
run: ./mvnw verify
- name: Upload libs to Gitea Maven Registry
- name: Upload libs to Forgejo Maven Registry
if: gitea.ref == 'refs/heads/main'
run: ./mvnw deploy -Dmaven.test.skip=true -Dmaven.javadoc.skip=true