From fca1a913406d220cba30c52e1b65a9d04e90822d Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Tue, 9 Jan 2024 15:50:08 -0600 Subject: [PATCH] URL encode any invalid key characters (#93) * URL encode any invalid key characters * Test we handle invalid chars * Job matrices must match * Empty commit * Empty commit --- .github/workflows/CI.yml | 2 ++ action.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a08ba8b..68146f8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -39,6 +39,7 @@ jobs: dep: - name: pandoc_jll version: "3" + invalid-chars: "," # Use invalid characters in job matrix to ensure we escape them os: - ubuntu-latest - windows-latest @@ -90,6 +91,7 @@ jobs: dep: - name: pandoc_jll version: "3" + invalid-chars: "," # Use invalid characters in job matrix to ensure we escape them os: - ubuntu-latest - windows-latest diff --git a/action.yml b/action.yml index 234ae79..eb2929c 100644 --- a/action.yml +++ b/action.yml @@ -95,6 +95,9 @@ runs: matrix_key=$(echo "$MATRIX_JSON" | jq 'paths(type != "object") as $p | ($p | join("-")) + "=" + (getpath($p) | tostring)' | jq -rs 'join(";") | . + ";"') fi restore_key="${{ inputs.cache-name }};os=${{ runner.os }};${matrix_key}" + # URL encode any restricted characters: + # https://github.com/actions/toolkit/blob/5430c5d84832076372990c7c27f900878ff66dc9/packages/cache/src/cache.ts#L38-L43 + restore_key=$(sed 's/,/%2C/g' <<<"${restore_key}") key="${restore_key}run_id=${{ github.run_id }};run_attempt=${{ github.run_attempt }}" echo "restore-key=${restore_key}" >> $GITHUB_OUTPUT echo "key=${key}" >> $GITHUB_OUTPUT