From bac39ba86046b68a16ed00142b7c91f2480bd893 Mon Sep 17 00:00:00 2001 From: Robert Lemke Date: Wed, 22 Jan 2020 11:18:44 +0100 Subject: [PATCH] Initial commit --- .github/workflows/docker.release.yaml | 58 +++++++++++++++++++++++++++ Dockerfile | 20 +++++++++ LICENSE | 22 ++++++++++ README.md | 5 +++ entrypoint.sh | 45 +++++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 .github/workflows/docker.release.yaml create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 entrypoint.sh diff --git a/.github/workflows/docker.release.yaml b/.github/workflows/docker.release.yaml new file mode 100644 index 0000000..fc1df53 --- /dev/null +++ b/.github/workflows/docker.release.yaml @@ -0,0 +1,58 @@ +name: Build and release Docker images +on: + push: + branches-ignore: + - '**' + tags: + - 'v*.*.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Build Docker image + uses: flownative/action-docker-build@v1 + with: + tag_ref: ${{ github.ref }} + git_repository_url: https://github.com/${{ github.repository }} + git_sha: ${{ github.sha }} + image_name: flownative/docker-action-helm-release/action-helm-release + registry_password: ${{ secrets.GITHUB_TOKEN }} + + - name: Determine latest released version + id: latest_version + uses: flownative/action-git-latest-release@master + + - name: Tag semver releases + uses: flownative/action-docker-publish-semver@master + with: + tag_ref: ${{ steps.latest_version.outputs.tag }} + tag_latest: 'yes' + + source_image_name: docker.pkg.github.com/flownative/docker-action-helm-release/action-helm-release + source_registry_username: github + source_registry_password: ${{ secrets.GITHUB_TOKEN }} + source_registry_endpoint: https://docker.pkg.github.com/v2/ + + target_image_name: docker.pkg.github.com/flownative/docker-action-helm-release/action-helm-release + target_registry_username: github + target_registry_password: ${{ secrets.GITHUB_TOKEN }} + target_registry_endpoint: https://docker.pkg.github.com/v2/ + + - name: Publish release to docker.io + uses: flownative/action-docker-publish-semver@master + with: + tag_ref: ${{ steps.latest_version.outputs.tag }} + tag_latest: 'yes' + + source_image_name: docker.pkg.github.com/flownative/docker-action-helm-release/action-helm-release + source_registry_username: github + source_registry_password: ${{ secrets.GITHUB_TOKEN }} + source_registry_endpoint: https://docker.pkg.github.com/v2/ + + target_image_name: flownative/action-helm-release + target_registry_username: ${{ secrets.DOCKER_IO_REGISTRY_USER }} + target_registry_password: ${{ secrets.DOCKER_IO_REGISTRY_PASSWORD }} + target_registry_endpoint: https://index.docker.io/v1/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6e9b6d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM flownative/base:1 + +ENV HELM_VERSION v3.0.2 +ENV HELM_HOME=/root/.helm + +# We need Git for "helm plugin install" +RUN apt-get update \ + && apt-get install git \ + && 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 \ + && mv linux-amd64/helm /usr/local/bin/helm \ + && rm -rf linux-amd64 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod 755 /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..91c9a81 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ + +The MIT License (MIT) + +Copyright (c) 2020 Robert Lemke, Flownative GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef4a2a7 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Docker Image for the Helm Release Github Action + +This is a the actual implementation of the [Flownative Github Action for releasing Helm charts](https://github.com/flownative/action-helm-release). +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. diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..9e77720 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,45 @@ +#!/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" + exit 1 +fi + +if [ -z "${INPUT_REPOSITORY_USER}" ]; then + echo "repository_user is not set" + exit 1 +fi + +if [ -z "${INPUT_REPOSITORY_PASSWORD}" ]; then + echo "repository_password is not set" + exit 1 +fi + +if [ -z "${INPUT_CHART_VERSION}" ]; then + echo "chart_version is not set" + exit 1 +fi + +if [ -z "${INPUT_APP_VERSION}" ]; then + echo "app_version is not set" + exit 1 +fi + +INPUT_CHART_VERSION=$(echo "${INPUT_CHART_VERSION}" | sed -e 's|refs/tags||' | sed -e 's/^v//') +INPUT_APP_VERSION=$(echo "${INPUT_APP_VERSION}" | sed -e 's|refs/tags||' | sed -e 's/^v//' | sed -e 's/+.*//') + +cd "${INPUT_CHARTS_FOLDER}" + +helm inspect chart "${INPUT_CHART_NAME}" +helm package --app-version "${INPUT_APP_VERSION}" --version "${INPUT_CHART_VERSION}" "${INPUT_CHART_NAME}" +helm push "${INPUT_CHART_NAME}-${INPUT_CHART_VERSION}.tgz" "${INPUT_REPOSITORY_URL}" --username "${INPUT_REPOSITORY_USER}" --password "${INPUT_REPOSITORY_PASSWORD}" --force