Skip to content

Commit b6de20b

Browse files
committed
fix: correct tar archive structure for action cache
The runner expects tar.gz to contain the action directory, not just its contents. Previous: tar -czf SHA.tar.gz -C /tmp/repo --exclude=.git . Result: tar contains files directly (wrong structure) Error: 'contains 4 directories' Fixed: tar -czf SHA.tar.gz -C /tmp {owner}_{repo} Result: tar contains one directory named {owner}_{repo} Matches runner's expected format This ensures the runner can properly extract and use cached actions.
1 parent 7cf54bd commit b6de20b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cache_github_actions.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ cache_action() {
2727

2828
# Clone the repo and get the commit SHA for the ref
2929
local temp_dir=$(mktemp -d)
30-
if ! git clone --depth=1 --branch "$ref" "https://github.com/${owner}/${repo}.git" "$temp_dir" 2>/dev/null; then
30+
if ! git clone --depth=1 --branch "$ref" "https://github.com/${owner}/${repo}.git" "$temp_dir/${owner}_${repo}" 2>/dev/null; then
3131
echo " ⚠ Warning: Failed to clone ${owner}/${repo}@${ref}, skipping"
3232
rm -rf "$temp_dir"
3333
return 0
3434
fi
3535

36-
local sha=$(cd "$temp_dir" && git rev-parse HEAD)
36+
local sha=$(cd "$temp_dir/${owner}_${repo}" && git rev-parse HEAD)
3737

38-
# Create tar.gz with the action content (exclude .git)
39-
tar -czf "${action_dir}/${sha}.tar.gz" -C "$temp_dir" --exclude=.git .
38+
# Remove .git directory to reduce size
39+
rm -rf "$temp_dir/${owner}_${repo}/.git"
40+
41+
# Create tar.gz with the action directory itself (not just its contents)
42+
# Runner expects: tar contains one directory named {owner}_{repo}
43+
tar -czf "${action_dir}/${sha}.tar.gz" -C "$temp_dir" "${owner}_${repo}"
4044

4145
# Clean up
4246
rm -rf "$temp_dir"

0 commit comments

Comments
 (0)