|
| 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