Skip to content

Commit

Permalink
ci: introduce a workflow for populating Maven cache that can be share…
Browse files Browse the repository at this point in the history
…d amongst workflows

Part of #1656

[skip ci]
  • Loading branch information
php-coder committed Jan 5, 2024
1 parent f0c15c5 commit 41ba556
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ updates:
directory: "/"
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#allow
allow:
- dependency-name: "actions/cache"
- dependency-name: "actions/checkout"
- dependency-name: "actions/setup-java"
- dependency-name: "actions/upload-artifact"
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/populate-maven-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Populates a cache for Maven

on:
push:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpull_requestpull_request_targetbranchesbranches-ignore
branches:
- master
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore
paths:
- pom.xml
- .github/workflows/populate-maven-cache.yml
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatch
workflow_dispatch:

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read # for "git clone"

defaults:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
run:
# Enable fail-fast behavior using set -eo pipefail
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash

jobs:
populate-maven-cache:
name: Populate Maven cache
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-20.04
steps:

- name: Clone source code
uses: actions/[email protected] # https://github.com/actions/checkout
with:
# Whether to configure the token or SSH key with the local git config. Default: true
persist-credentials: false

- name: Install JDK
uses: actions/[email protected] # https://github.com/actions/setup-java
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax

- name: Restore existing cache copy
uses: actions/[email protected] # https://github.com/actions/cache
with:
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository

- name: Download all dependencies
run: mvn dependency:resolve dependency:resolve-plugins

0 comments on commit 41ba556

Please sign in to comment.