Skip to content

Commit

Permalink
Fix incorrect sha calculation for caching (#43)
Browse files Browse the repository at this point in the history
* Fix incorrect sha calculation for caching

* update changelog
  • Loading branch information
rcannood authored Dec 10, 2024
1 parent 80d1c9f commit 67da3e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# viash-actions v6.6.1

## Bug fixes

* `project/sync-and-cache`: Fix incorrect sha calculation for caching (PR #43).

# viash-actions v6.6.0

## New functionality
Expand Down
36 changes: 19 additions & 17 deletions project/sync-and-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,34 @@ runs:
exit 0
fi
function hash_s3() {
function s3_ls() {
local s3_path="$1"
AWS_EC2_METADATA_DISABLED=true \
aws s3 ls \
"$s3_path" \
--recursive \
--no-sign-request | \
md5sum | \
awk '{ print $1 }'
--no-sign-request
}
hashes=()
ls_content=$(
echo "${{ steps.test_resources.outputs.test_resources }}" | \
while read -r line; do
type=$(echo "$line" | yq e '.type')
path=$(echo "$line" | yq e '.path')
dest=$(echo "$line" | yq e '.dest')
echo "${{ steps.test_resources.outputs.test_resources }}" | \
while read -r line; do
type=$(echo "$line" | yq e '.type')
path=$(echo "$line" | yq e '.path')
dest=$(echo "$line" | yq e '.dest')
if [ "$type" == "s3" ]; then
hash=$(hash_s3 "$path")
fi
echo "dest: $dest, hash: $hash"
hashes+=( "dest: $dest, hash: $hash" )
done
echo "# type: $type, path: $path, dest: $dest"
echo ""
if [ "$type" == "s3" ]; then
s3_ls "$path"
fi
echo ""
done
)
hash=$(echo "${hashes[@]}" | md5sum | awk '{ print $1 }')
hash=$(echo "${ls_content}" | md5sum | awk '{ print $1 }')
echo "cache_key=${{ inputs.cache_key_prefix }}$hash" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 67da3e5

Please sign in to comment.