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
This commit is contained in:
Curtis Vogt
2024-01-09 15:50:08 -06:00
committed by GitHub
parent 207a5a0786
commit fca1a91340
2 changed files with 5 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ jobs:
dep: dep:
- name: pandoc_jll - name: pandoc_jll
version: "3" version: "3"
invalid-chars: "," # Use invalid characters in job matrix to ensure we escape them
os: os:
- ubuntu-latest - ubuntu-latest
- windows-latest - windows-latest
@@ -90,6 +91,7 @@ jobs:
dep: dep:
- name: pandoc_jll - name: pandoc_jll
version: "3" version: "3"
invalid-chars: "," # Use invalid characters in job matrix to ensure we escape them
os: os:
- ubuntu-latest - ubuntu-latest
- windows-latest - windows-latest

View File

@@ -95,6 +95,9 @@ runs:
matrix_key=$(echo "$MATRIX_JSON" | jq 'paths(type != "object") as $p | ($p | join("-")) + "=" + (getpath($p) | tostring)' | jq -rs 'join(";") | . + ";"') matrix_key=$(echo "$MATRIX_JSON" | jq 'paths(type != "object") as $p | ($p | join("-")) + "=" + (getpath($p) | tostring)' | jq -rs 'join(";") | . + ";"')
fi fi
restore_key="${{ inputs.cache-name }};os=${{ runner.os }};${matrix_key}" 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 }}" key="${restore_key}run_id=${{ github.run_id }};run_attempt=${{ github.run_attempt }}"
echo "restore-key=${restore_key}" >> $GITHUB_OUTPUT echo "restore-key=${restore_key}" >> $GITHUB_OUTPUT
echo "key=${key}" >> $GITHUB_OUTPUT echo "key=${key}" >> $GITHUB_OUTPUT