Skip to content

Commit

Permalink
Merge pull request #3 from flownative/feature/oci
Browse files Browse the repository at this point in the history
Migrate to OCI repositories
  • Loading branch information
robertlemke authored Sep 16, 2024
2 parents 1efbfc2 + 458e691 commit e04dd52
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
17 changes: 10 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/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
echo "chart_name is not set"
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

Expand Down Expand Up @@ -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}"

0 comments on commit e04dd52

Please sign in to comment.