Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ branding:
color: blue
icon: anchor
inputs:
verify_blob:
description: "determines whether the download blob should be verified (default: true)"
default: 'true'
Comment thread
fty4 marked this conversation as resolved.
Comment thread
fty4 marked this conversation as resolved.
version:
description: "The chart-testing version to install (default: 3.9.0)"
required: false
Expand All @@ -24,6 +27,7 @@ runs:
- run: |
cd $GITHUB_ACTION_PATH \
&& ./ct.sh \
--verify-blob ${{ inputs.verify_blob }} \
--version ${{ inputs.version }} \
--yamllint-version ${{ inputs.yamllint_version }} \
--yamale-version ${{ inputs.yamale_version }}
Expand Down
38 changes: 26 additions & 12 deletions ct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -o nounset
set -o pipefail

DEFAULT_CHART_TESTING_VERSION=3.9.0
DEFAULT_VERIFY_BLOB=true
DEFAULT_YAMLLINT_VERSION=1.27.1
DEFAULT_YAMALE_VERSION=3.0.4

Expand All @@ -19,6 +20,7 @@ EOF

main() {
local version="${DEFAULT_CHART_TESTING_VERSION}"
local verify_blob="${DEFAULT_VERIFY_BLOB}"
local yamllint_version="${DEFAULT_YAMLLINT_VERSION}"
local yamale_version="${DEFAULT_YAMALE_VERSION}"

Expand All @@ -34,6 +36,16 @@ parse_command_line() {
show_help
exit
;;
--verify-blob)
if [[ -n "${2:-}" ]]; then
verify_blob="${2#v}"
shift
else
echo "ERROR: '--verify-blob' cannot be empty." >&2
show_help
exit 1
fi
;;
-v|--version)
if [[ -n "${2:-}" ]]; then
version="${2#v}"
Expand Down Expand Up @@ -88,21 +100,23 @@ install_chart_testing() {
local cache_dir="${RUNNER_TOOL_CACHE}/ct/${version}/${arch}"
local venv_dir="${cache_dir}/venv"

curl --retry 5 --retry-delay 1 -sSLo ct.tar.gz "https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz"
if [[ ! -d "${cache_dir}" ]]; then
mkdir -p "${cache_dir}"

echo "Installing chart-testing v${version}..."
CT_CERT=https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz.pem
CT_SIG=https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz.sig

curl --retry 5 --retry-delay 1 -sSLo ct.tar.gz "https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz"
cosign verify-blob --certificate $CT_CERT --signature $CT_SIG \
--certificate-identity "https://github.com/helm/chart-testing/.github/workflows/release.yaml@refs/heads/main" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" ct.tar.gz
retVal=$?
if [[ "${retVal}" -ne 0 ]]; then
log_error "Unable to validate chart-testing version: v${version}"
exit 1
if [[ "${verify_blob}" != "false" ]]; then
echo "Installing chart-testing v${version}..."
CT_CERT=https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz.pem
CT_SIG=https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz.sig

cosign verify-blob --certificate $CT_CERT --signature $CT_SIG \
--certificate-identity "https://github.com/helm/chart-testing/.github/workflows/release.yaml@refs/heads/main" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" ct.tar.gz
retVal=$?
if [[ "${retVal}" -ne 0 ]]; then
log_error "Unable to validate chart-testing version: v${version}"
exit 1
fi
fi

tar -xzf ct.tar.gz -C "${cache_dir}"
Expand Down