Skip to content

Commit 41ba556

Browse files
committed
ci: introduce a workflow for populating Maven cache that can be shared amongst workflows
Part of #1656 [skip ci]
1 parent f0c15c5 commit 41ba556

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.github/dependabot.yml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ updates:
3838
directory: "/"
3939
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#allow
4040
allow:
41+
- dependency-name: "actions/cache"
4142
- dependency-name: "actions/checkout"
4243
- dependency-name: "actions/setup-java"
4344
- dependency-name: "actions/upload-artifact"
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Populates a cache for Maven
2+
3+
on:
4+
push:
5+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpull_requestpull_request_targetbranchesbranches-ignore
6+
branches:
7+
- master
8+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore
9+
paths:
10+
- pom.xml
11+
- .github/workflows/populate-maven-cache.yml
12+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch
13+
workflow_dispatch:
14+
15+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
16+
permissions:
17+
contents: read # for "git clone"
18+
19+
defaults:
20+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
21+
run:
22+
# Enable fail-fast behavior using set -eo pipefail
23+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
24+
shell: bash
25+
26+
jobs:
27+
populate-maven-cache:
28+
name: Populate Maven cache
29+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
30+
runs-on: ubuntu-20.04
31+
steps:
32+
33+
- name: Clone source code
34+
uses: actions/[email protected] # https://github.com/actions/checkout
35+
with:
36+
# Whether to configure the token or SSH key with the local git config. Default: true
37+
persist-credentials: false
38+
39+
- name: Install JDK
40+
uses: actions/[email protected] # https://github.com/actions/setup-java
41+
with:
42+
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
43+
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
44+
45+
- name: Restore existing cache copy
46+
uses: actions/[email protected] # https://github.com/actions/cache
47+
with:
48+
key: maven-repository-${{ hashFiles('pom.xml') }}
49+
path: ~/.m2/repository
50+
51+
- name: Download all dependencies
52+
run: mvn dependency:resolve dependency:resolve-plugins

0 commit comments

Comments
 (0)