@@ -25,6 +25,17 @@ inputs:
2525runs :
2626 using : ' composite'
2727 steps :
28+ # Check if this is a rerun of a previous workflow run
29+ - name : 🔄 Check for Rerun
30+ id : check-rerun
31+ shell : bash
32+ run : |
33+ if [ "${{ github.run_attempt }}" -gt 1 ]; then
34+ echo "rerun_suffix=-rerun${{ github.run_attempt }}" >> $GITHUB_OUTPUT
35+ else
36+ echo "rerun_suffix=" >> $GITHUB_OUTPUT
37+ fi
38+
2839 # Generate standard cache keys
2940 - name : 🔑 Generate Cache Keys
3041 id : generate-keys
@@ -35,17 +46,22 @@ runs:
3546 NAME="${{ inputs.name }}"
3647 OS="${{ runner.os }}"
3748 RUN_ID="${{ github.run_id }}"
49+ RERUN_SUFFIX="${{ steps.check-rerun.outputs.rerun_suffix }}"
50+
51+ # Generate platform-specific key (no cross-platform sharing to avoid path issues)
52+ PLATFORM_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
53+ echo "platform_key=${PLATFORM_KEY}" >> $GITHUB_OUTPUT
3854
39- # Generate standard key (os-specific)
40- STANDARD_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}"
55+ # Generate standard key (os-specific) for backward compatibility
56+ STANDARD_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX} "
4157 echo "standard_key=${STANDARD_KEY}" >> $GITHUB_OUTPUT
4258
4359 # Generate OS-agnostic key
44- AGNOSTIC_KEY="${CACHE_PREFIX}-${NAME}-${RUN_ID}"
60+ AGNOSTIC_KEY="${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX} "
4561 echo "agnostic_key=${AGNOSTIC_KEY}" >> $GITHUB_OUTPUT
4662
4763 # Generate Linux-specific key for cross-OS compatibility
48- LINUX_KEY="Linux-${CACHE_PREFIX}-${NAME}-${RUN_ID}"
64+ LINUX_KEY="Linux-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX} "
4965 echo "linux_key=${LINUX_KEY}" >> $GITHUB_OUTPUT
5066
5167 # Generate pattern keys
@@ -80,38 +96,24 @@ runs:
8096 lookup-only : false
8197 fail-on-cache-miss : false
8298
83- # Restore with standard key (os -specific)
84- - name : 🗄️ Restore with Standard Key
85- id : cache-restore-standard
99+ # Restore with platform -specific key
100+ - name : 🗄️ Restore with Platform-Specific Key
101+ id : cache-restore-platform
86102 if : steps.cache-restore-exact.outputs.cache-hit != 'true'
87103 uses : actions/cache/restore@v4
88104 env :
89105 ACTIONS_CACHE_SERVICE_V2 : ' true'
90106 with :
91107 path : ${{ steps.normalize-path.outputs.normalized_path }}
92- key : ${{ steps.generate-keys.outputs.standard_key }}
93- enableCrossOsArchive : true
94- lookup-only : false
95- fail-on-cache-miss : false
96-
97- # Restore with OS-agnostic key
98- - name : 🗄️ Restore with OS-Agnostic Key
99- id : cache-restore-agnostic
100- if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true'
101- uses : actions/cache/restore@v4
102- env :
103- ACTIONS_CACHE_SERVICE_V2 : ' true'
104- with :
105- path : ${{ steps.normalize-path.outputs.normalized_path }}
106- key : ${{ steps.generate-keys.outputs.agnostic_key }}
108+ key : ${{ steps.generate-keys.outputs.platform_key }}
107109 enableCrossOsArchive : true
108110 lookup-only : false
109111 fail-on-cache-miss : false
110112
111113 # Restore with Linux key for cross-OS compatibility
112114 - name : 🗄️ Restore with Linux Key
113115 id : cache-restore-linux
114- if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true' && steps.cache-restore-agnostic .outputs.cache-hit != 'true' && runner.os != 'Linux'
116+ if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-platform .outputs.cache-hit != 'true' && runner.os != 'Linux'
115117 uses : actions/cache/restore@v4
116118 env :
117119 ACTIONS_CACHE_SERVICE_V2 : ' true'
@@ -125,7 +127,7 @@ runs:
125127 # Try OS-specific pattern as fallback (finds latest matching cache)
126128 - name : 🗄️ Restore with Pattern
127129 id : cache-restore-pattern
128- if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true' && steps.cache-restore-agnostic .outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true'
130+ if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-platform .outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true'
129131 uses : actions/cache/restore@v4
130132 env :
131133 ACTIONS_CACHE_SERVICE_V2 : ' true'
@@ -140,7 +142,7 @@ runs:
140142
141143 # Handle cache miss
142144 - name : ⚠️ Handle Cache Miss
143- if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true' && steps.cache-restore-agnostic .outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true' && steps.cache-restore-pattern.outputs.cache-hit != 'true'
145+ if : steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-platform .outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true' && steps.cache-restore-pattern.outputs.cache-hit != 'true'
144146 shell : bash
145147 run : |
146148 if [ -n "${{ inputs.use_cache }}" ] && [ "${{ inputs.use_cache }}" = "true-only" ]; then
@@ -160,10 +162,8 @@ runs:
160162 # Summary of what method was used to get the file (for debugging)
161163 if [ "${{ steps.cache-restore-exact.outputs.cache-hit }}" == "true" ]; then
162164 SOURCE="exact key cache"
163- elif [ "${{ steps.cache-restore-standard.outputs.cache-hit }}" == "true" ]; then
164- SOURCE="standard key cache"
165- elif [ "${{ steps.cache-restore-agnostic.outputs.cache-hit }}" == "true" ]; then
166- SOURCE="OS-agnostic key cache"
165+ elif [ "${{ steps.cache-restore-platform.outputs.cache-hit }}" == "true" ]; then
166+ SOURCE="platform-specific key cache"
167167 elif [ "${{ steps.cache-restore-linux.outputs.cache-hit }}" == "true" ]; then
168168 SOURCE="Linux key cache"
169169 elif [ "${{ steps.cache-restore-pattern.outputs.cache-hit }}" == "true" ]; then
0 commit comments