Skip to content

Commit e7ace49

Browse files
committed
Updates save action
1 parent c7fa1f5 commit e7ace49

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

.github/actions/gh-cache/save/action.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,24 @@ runs:
6464
shell: bash
6565
run: |
6666
if [ -e "${{ inputs.path }}" ]; then
67-
mkdir -p ".gh-cache-${{ github.run_id }}/$(dirname "${{ inputs.path }}")"
6867
if [ -d "${{ inputs.path }}" ]; then
68+
# For directories, copy contents to avoid nesting
6969
mkdir -p ".gh-cache-${{ github.run_id }}/${{ inputs.path }}"
70-
cp -Rf "${{ inputs.path }}/." ".gh-cache-${{ github.run_id }}/${{ inputs.path }}/"
70+
# Check if directory has files before copying
71+
if [ "$(ls -A "${{ inputs.path }}" 2>/dev/null)" ]; then
72+
cp -Rf "${{ inputs.path }}"/* ".gh-cache-${{ github.run_id }}/${{ inputs.path }}"/
73+
echo "Copied directory contents of '${{ inputs.path }}' to 'gh-cache' branch"
74+
else
75+
echo "Directory '${{ inputs.path }}' is empty, nothing to copy"
76+
fi
7177
else
78+
# For files, copy file to path
79+
mkdir -p ".gh-cache-${{ github.run_id }}/$(dirname "${{ inputs.path }}")"
7280
cp -Rf "${{ inputs.path }}" ".gh-cache-${{ github.run_id }}/${{ inputs.path }}"
81+
echo "Copied file '${{ inputs.path }}' to 'gh-cache' branch"
7382
fi
74-
echo "Copied '${{ inputs.path }}' to 'gh-cache' branch"
7583
else
7684
echo "'${{ inputs.path }}' does not exist"
77-
echo "Skipping copy"
7885
fi
7986
8087
- name: Commit and push

0 commit comments

Comments
 (0)