Skip to content

Commit

Permalink
Merge pull request #31 from nayuta/use_temp_dir_for_download
Browse files Browse the repository at this point in the history
Use temporary directory for download trivy
  • Loading branch information
shogo82148 committed Mar 20, 2024
2 parents e4c2f18 + 8bf4f60 commit 197124f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ echo '::endgroup::'
echo "::group:: Installing trivy (${INPUT_TRIVY_VERSION}) ... https://github.com/aquasecurity/trivy"
test ! -d "${TRIVY_PATH}" && install -d "${TRIVY_PATH}"

PREV_DIR=$(pwd)
TEMP_DOWNLOAD_PATH="$(mktemp -d)"
cd "${TEMP_DOWNLOAD_PATH}" || exit

archive="trivy.${archive_extension}"
if [[ "${INPUT_TRIVY_VERSION}" = "latest" ]]; then
# latest release is available on this url.
Expand All @@ -58,17 +62,23 @@ echo "::group:: Installing trivy (${INPUT_TRIVY_VERSION}) ... https://github.com
release_num=${release/#v/}
url="https://github.com/aquasecurity/trivy/releases/download/${release}/trivy_${release_num}_${os}-${arch}.${archive_extension}"
# Echo url for testing
echo "Downloading ${url}"

echo "Downloading ${url} to ${archive}"
curl --silent --show-error --fail \
--location "${url}" \
--output "${archive}"

### TEST
echo "URL: ${url}"
echo "ARCHIVE: ${archive}"
ls
### TEST END
if [[ "${os}" = "Windows" ]]; then
unzip "${archive}"
else
tar -xzf "${archive}"
fi
install trivy "${TRIVY_PATH}"
cd "${PREV_DIR}" || exit
echo '::endgroup::'

echo "::group:: Print trivy details ..."
Expand Down

0 comments on commit 197124f

Please sign in to comment.