-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When running the action twice in a job, it fails because the directory we tried to create already exists. Check if there already is a binary and that it is the version we expect. This also saves us a bit of time by avoiding a re-download. Finally, add e2e tests to cover all use-cases. PR: #135 Closes: #134 Co-Authored-By: Johan Bergström <[email protected]>
- Loading branch information
1 parent
624871f
commit b0e99c7
Showing
4 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
CI=${GITHUB_ACTIONS:-} | ||
|
||
[[ -n "${DEBUG}" ]] && set -x | ||
set -euo pipefail | ||
shopt -s nullglob globstar | ||
|
||
[[ -z ${CI} ]] && echo "Will only run in Github Actions" && exit 1 | ||
|
||
VERSION=${version:-} | ||
|
||
DOWNLOAD="false" | ||
# Check if hadolint is installed and compare versions to decide | ||
# if we should download a new version | ||
if [ -x "$(command -v hadolint)" ]; then | ||
INSTALLED_VERSION=$(hadolint --version | cut -d " " -f 4 2>&1) | ||
echo "::debug::Found existing Hadolint version: ${INSTALLED_VERSION}" | ||
if [ "${INSTALLED_VERSION}" != "${VERSION}" ]; then | ||
echo "::info::Hadolint version (${INSTALLED_VERSION}) does not match requested version (${VERSION})" | ||
DOWNLOAD="true" | ||
fi | ||
else | ||
DOWNLOAD="true" | ||
fi | ||
|
||
# Download hadolint if necessary | ||
if [ "${DOWNLOAD}" == "true" ]; then | ||
echo "::debug::Downloading Hadolint ${VERSION}" | ||
# https://github.com/actions/runner-images/issues/3727 | ||
# /usr/local/bin exists and is writable by any user | ||
curl -s -L --fail -w 1 -o /tmp/hadolint \ | ||
"https://github.com/hadolint/hadolint/releases/download/v${VERSION}/hadolint-Linux-x86_64" || | ||
(echo "::error::Hadolint (version: ${VERSION}) could not be found. Exiting." && exit 1) | ||
mv /tmp/hadolint /usr/local/bin/hadolint | ||
chmod +x /usr/local/bin/hadolint | ||
fi | ||
|
||
echo "::debug:: $(hadolint --version | cut -d " " -f 4 2>&1) installed successfully" |