From d1b395bb67404aeae7c7127928b3a9a75755c407 Mon Sep 17 00:00:00 2001 From: erabii Date: Fri, 15 Jul 2022 17:39:36 +0300 Subject: [PATCH] use branch name in the cache key (#1049) --- .github/workflows/maven.yaml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 1fa45cf6..8b69bbf6 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -21,13 +21,31 @@ jobs: with: distribution: 'temurin' java-version: '17' + + - name: Extract branch name + id: extract_branch + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF})" + - name: Cache local Maven repository + id: cache-maven-repo uses: actions/cache@v2 with: path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + key: ${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }} restore-keys: | - ${{ runner.os }}-maven- + ${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }} + + - if: ${{ steps.cache-maven-repo.outputs.cache-hit == 'false' }} + name: cache miss callback + continue-on-error: false + run: echo 'cache miss' + + - if: ${{ steps.cache-maven-repo.outputs.cache-hit == 'true' }} + name: cache hit callback + continue-on-error: false + run: echo 'cache hit' + - name: Build with Maven run: ./mvnw -s .settings.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 - name: Publish Test Report