From 458e691db6d9e13975804388c9981ac68adaf16b Mon Sep 17 00:00:00 2001 From: Robert Lemke Date: Mon, 16 Sep 2024 09:24:23 +0200 Subject: [PATCH] Migrate to OCI repositories Chart Museum support was dropped and instead this action now assumes and supports that the registry is OCI compatible. See the README for the new set of input variables. --- Dockerfile | 11 +++++------ README.md | 20 ++++++++++++++++++++ entrypoint.sh | 17 ++++++++++------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index abc4310..2ec7175 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,16 @@ -FROM flownative/base:bookworm +FROM ubuntu:latest -# For Helm releases see: https://github.com/helm/helm/releases -ENV HELM_VERSION v3.16.1 +ENV HELM_VERSION=v3.16.1 ENV HELM_HOME=/root/.helm -# We need Git for "helm plugin install" RUN apt-get update \ - && apt-get install git \ + && apt-get install git curl -y \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /var/log/apt \ && rm -rf /var/log/dpkg.log -RUN curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar xz \ +# For Helm releases see: https://github.com/helm/helm/releases +RUN curl -sSL "https://get.helm.sh/helm-v3.16.1-linux-amd64.tar.gz" | tar xz \ && mv linux-amd64/helm /usr/local/bin/helm \ && rm -rf linux-amd64 diff --git a/README.md b/README.md index 1f7f587..e932241 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,23 @@ This is the actual implementation of the The actual GitHub action refers to a pre-built image in its `Dockerfile`, so that the action image does not have to be re-built on every use. + +## Testing + +To test this action locally, build the image and run the container as follows: + +```shell +docker buildx build --platform linux/amd64 \ + --tag flownative/action-helm-release:dev --load . + +docker run --name workflow --rm \ + -e INPUT_APP_VERSION=2.133.1+5 + -e INPUT_CHART_VERSION=2.133.1+5 \ + -e INPUT_REGISTRY_HOST=dev.harbor.example.com \ + -e INPUT_REPOSITORY_PATH=acme-charts \ + -e INPUT_CHART_NAME=beach-my-app \ + -e INPUT_CHARTS_FOLDER=/application/Helm \ + -e INPUT_REPOSITORY_USER=robot#acme-charts+github-test \ + -e INPUT_REPOSITORY_PASSWORD=… \ + -v=$(pwd):/application docker.io/flownative/action-helm-release:dev +``` diff --git a/entrypoint.sh b/entrypoint.sh index f419895..0d43161 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,8 +1,6 @@ #!/bin/bash set -ex -helm plugin install https://github.com/chartmuseum/helm-push.git - export INPUT_CHARTS_FOLDER=${INPUT_CHARTS_FOLDER:-.} if [ -z "${INPUT_CHART_NAME}" ]; then @@ -10,8 +8,13 @@ if [ -z "${INPUT_CHART_NAME}" ]; then exit 1 fi -if [ -z "${INPUT_REPOSITORY_URL}" ]; then - echo "repository_url is not set" +if [ -z "${INPUT_REGISTRY_HOST}" ]; then + echo "registry_host is not set" + exit 1 +fi + +if [ -z "${INPUT_REPOSITORY_PATH}" ]; then + echo "repository_path is not set" exit 1 fi @@ -40,7 +43,7 @@ INPUT_APP_VERSION=$(echo "${INPUT_APP_VERSION}" | sed -e 's|refs/tags||' | sed - cd "${INPUT_CHARTS_FOLDER}" -helm inspect chart "${INPUT_CHART_NAME}" +helm inspect chart "${INPUT_CHARTS_FOLDER}"/"${INPUT_CHART_NAME}" helm package --app-version "${INPUT_APP_VERSION}" --version "${INPUT_CHART_VERSION}" "${INPUT_CHART_NAME}" -echo "${INPUT_REPOSITORY_PASSWORD}" | helm registry login -u "${INPUT_REPOSITORY_USER}" --password-stdin "${INPUT_REPOSITORY_URL}" -helm push --force "${INPUT_CHART_NAME}-${INPUT_CHART_VERSION}.tgz" "${INPUT_REPOSITORY_URL}" "${INPUT_REPOSITORY_URL}" +echo "${INPUT_REPOSITORY_PASSWORD}" | helm registry login -u "${INPUT_REPOSITORY_USER}" --password-stdin "${INPUT_REGISTRY_HOST}" +helm push "${INPUT_CHART_NAME}-${INPUT_CHART_VERSION}.tgz" "oci://${INPUT_REGISTRY_HOST}/${INPUT_REPOSITORY_PATH}/${INPUT_CHART_NAME}"