-
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.
chore: refactor install script into a separate file
- Loading branch information
1 parent
d77d78d
commit 5367ba2
Showing
3 changed files
with
39 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/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 exists | ||
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 "::debug::Hadolint version (${INSTALLED_VERSION}) does not match requested version (${VERSION})" | ||
DOWNLOAD="true" | ||
fi | ||
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 -L --fail -w "1" -o ./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 | ||
chmod +x /usr/local/bin/hadolint | ||
fi |