diff --git a/config-gradle/action.yml b/config-gradle/action.yml index 7d9fa4d3..e9695835 100644 --- a/config-gradle/action.yml +++ b/config-gradle/action.yml @@ -157,13 +157,21 @@ runs: rm -f gradle-md5-sums.txt + - name: Sanitize workflow name for cache key + id: sanitize_workflow + if: steps.config-gradle-completed.outputs.skip != 'true' && inputs.disable-caching == 'false' + shell: bash + env: + WORKFLOW_NAME: ${{ github.workflow }} + run: echo "workflow_name=${WORKFLOW_NAME// /-}" >> "$GITHUB_OUTPUT" + - name: Gradle Cache uses: SonarSource/gh-action_cache@v1 if: steps.config-gradle-completed.outputs.skip != 'true' && inputs.disable-caching == 'false' with: path: ${{ inputs.cache-paths }} - key: gradle-${{ runner.os }}-${{ github.workflow }}-${{ env.GRADLE_CACHE_KEY }} - restore-keys: gradle-${{ runner.os }}-${{ github.workflow }}- + key: gradle-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}-${{ env.GRADLE_CACHE_KEY }} + restore-keys: gradle-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}- # $GRADLE_USER_HOME is typically set to ~/.gradle/ by gradle/actions/setup-gradle - name: Configure Gradle Authentication diff --git a/config-maven/action.yml b/config-maven/action.yml index b46adb49..c3dcaede 100644 --- a/config-maven/action.yml +++ b/config-maven/action.yml @@ -168,13 +168,23 @@ runs: fi fi + - name: Sanitize workflow name for cache key + id: sanitize_workflow + if: steps.config-maven-completed.outputs.skip != 'true' && inputs.disable-caching == 'false' + shell: bash + env: + WORKFLOW_NAME: ${{ github.workflow }} + run: echo "workflow_name=${WORKFLOW_NAME// /-}" >> "$GITHUB_OUTPUT" + - name: Cache local Maven repository uses: SonarSource/gh-action_cache@v1 if: steps.config-maven-completed.outputs.skip != 'true' && inputs.disable-caching == 'false' with: path: ${{ inputs.cache-paths }} - key: maven-${{ runner.os }}-${{ github.workflow }}-${{ hashFiles(format('{0}/**/pom.xml', inputs.working-directory)) }} - restore-keys: maven-${{ runner.os }}-${{ github.workflow }}- + # yamllint disable rule:line-length + key: maven-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}-${{ hashFiles(format('{0}/**/pom.xml', inputs.working-directory)) }} + # yamllint enable rule:line-length + restore-keys: maven-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}- - name: Update project version and set current-version and project-version variables id: set-version diff --git a/config-npm/action.yml b/config-npm/action.yml index 586943fc..9d4c7f99 100644 --- a/config-npm/action.yml +++ b/config-npm/action.yml @@ -97,13 +97,21 @@ runs: rmdir "${{ steps.setup.outputs.MISE_BACKUP }}" echo "::endgroup::" + - name: Sanitize workflow name for cache key + id: sanitize_workflow + if: ${{ inputs.cache-npm == 'true' }} + shell: bash + env: + WORKFLOW_NAME: ${{ github.workflow }} + run: echo "workflow_name=${WORKFLOW_NAME// /-}" >> "$GITHUB_OUTPUT" + - name: Cache NPM dependencies uses: SonarSource/gh-action_cache@v1 if: ${{ inputs.cache-npm == 'true' }} with: path: ~/.npm - key: npm-${{ runner.os }}-${{ github.workflow }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: npm-${{ runner.os }}-${{ github.workflow }}- + key: npm-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: npm-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}- - name: Check for package.json id: check_package_json diff --git a/config-pip/action.yml b/config-pip/action.yml index 5bd83f17..edbe936e 100644 --- a/config-pip/action.yml +++ b/config-pip/action.yml @@ -91,12 +91,22 @@ runs: ARTIFACTORY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_ACCESS_TOKEN }} run: $ACTION_PATH_CONFIG_PIP/config.sh + - name: Sanitize workflow name for cache key + id: sanitize_workflow + if: inputs.disable-caching == 'false' + shell: bash + env: + WORKFLOW_NAME: ${{ github.workflow }} + run: echo "workflow_name=${WORKFLOW_NAME// /-}" >> "$GITHUB_OUTPUT" + - name: Cache pip dependencies uses: SonarSource/gh-action_cache@v1 if: inputs.disable-caching == 'false' with: path: ${{ inputs.cache-paths }} - key: pip-${{ runner.os }}-${{ github.workflow }}-${{ hashFiles(format('{0}/requirements*.txt', inputs.working-directory), + # yamllint disable rule:line-length + key: pip-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}-${{ hashFiles(format('{0}/requirements*.txt', inputs.working-directory), format('{0}/Pipfile.lock', inputs.working-directory), format('{0}/poetry.lock', inputs.working-directory), format('{0}/pyproject.toml', inputs.working-directory)) }} - restore-keys: pip-${{ runner.os }}-${{ github.workflow }}- + # yamllint enable rule:line-length + restore-keys: pip-${{ runner.os }}-${{ steps.sanitize_workflow.outputs.workflow_name }}-