From ade295d5a3f2de0b06525d3ca6c45e8c29967784 Mon Sep 17 00:00:00 2001 From: Steven Sheehy Date: Fri, 7 Aug 2020 15:41:33 -0500 Subject: [PATCH 1/3] Add target_dir option Signed-off-by: Steven Sheehy --- README.md | 2 ++ action.yml | 6 +++++- src/entrypoint.sh | 12 +++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5e4063a..66c5f98 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Inputs: * `repository` The GitHub repository, defaults to the `GITHUB_REPOSITORY` env var * `branch` The branch to publish charts, defaults to `gh-pages` * `helm_version` The Helm CLI version, defaults to the latest release +* `target_dir` The target directory to store the charts, defaults to `.` ## Examples @@ -56,4 +57,5 @@ jobs: owner: fluxcd repository: charts branch: gh-pages + target_dir: charts ``` diff --git a/action.yml b/action.yml index 55f9642..2b45bfa 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,9 @@ inputs: helm_version: description: "The Helm CLI version" required: false + target_dir: + description: "The target directory to store the charts, defaults to `.`" + required: false runs: using: 'docker' image: 'Dockerfile' @@ -36,4 +39,5 @@ runs: - ${{ inputs.user }} - ${{ inputs.repository }} - ${{ inputs.branch }} - - ${{ inputs.helm_version }} \ No newline at end of file + - ${{ inputs.helm_version }} + - ${{ inputs.target_dir }} diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 1fada32..02d3e62 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -10,6 +10,7 @@ OWNER=$4 REPOSITORY=$5 BRANCH=$6 HELM_VERSION=$7 +TARGET_DIR=$8 CHARTS=() CHARTS_TMP_DIR=$(mktemp -d) @@ -37,6 +38,10 @@ main() { BRANCH="gh-pages" fi + if [[ -z "$TARGET_DIR" ]]; then + TARGET_DIR="." + fi + if [[ -z "$CHARTS_URL" ]]; then CHARTS_URL="https://${OWNER}.github.io/${REPOSITORY}" fi @@ -103,10 +108,11 @@ upload() { charts=$(cd ${CHARTS_TMP_DIR} && ls *.tgz | xargs) - mv -f ${CHARTS_TMP_DIR}/*.tgz . - helm repo index . --url ${CHARTS_URL} + mkdir -p ${TARGET_DIR} + mv -f ${CHARTS_TMP_DIR}/*.tgz ${TARGET_DIR} + helm repo index ${TARGET_DIR} --url ${CHARTS_URL} - git add . + git add ${TARGET_DIR} git commit -m "Publish $charts" git push origin gh-pages From 46238520ad62f8473ca8a5b0d3cc1447e03cbb98 Mon Sep 17 00:00:00 2001 From: Steven Sheehy Date: Fri, 7 Aug 2020 15:48:30 -0500 Subject: [PATCH 2/3] Fix chart URL with target_dir Signed-off-by: Steven Sheehy --- src/entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 02d3e62..ebed7ae 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -46,6 +46,10 @@ main() { CHARTS_URL="https://${OWNER}.github.io/${REPOSITORY}" fi + if [[ "$TARGET_DIR" != "." ]]; then + CHARTS_URL="${CHARTS_URL}/${TARGET_DIR}" + fi + if [[ -z "$REPO_URL" ]]; then REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${OWNER}/${REPOSITORY}" fi From bc6fa4a52ed3029359e20d5d44916045cc0ea02c Mon Sep 17 00:00:00 2001 From: Steven Sheehy Date: Mon, 10 Aug 2020 15:33:16 -0500 Subject: [PATCH 3/3] Address review feedback Signed-off-by: Steven Sheehy --- README.md | 2 +- action.yml | 8 ++++---- src/entrypoint.sh | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 66c5f98..c9c46a3 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Inputs: * `owner` The GitHub user or org that owns this repository, defaults to the owner in `GITHUB_REPOSITORY` env var * `repository` The GitHub repository, defaults to the `GITHUB_REPOSITORY` env var * `branch` The branch to publish charts, defaults to `gh-pages` -* `helm_version` The Helm CLI version, defaults to the latest release * `target_dir` The target directory to store the charts, defaults to `.` +* `helm_version` The Helm CLI version, defaults to the latest release ## Examples diff --git a/action.yml b/action.yml index 2b45bfa..1ab5448 100644 --- a/action.yml +++ b/action.yml @@ -23,12 +23,12 @@ inputs: branch: description: "The branch to publish charts, defaults to `gh-pages`" required: false - helm_version: - description: "The Helm CLI version" - required: false target_dir: description: "The target directory to store the charts, defaults to `.`" required: false + helm_version: + description: "The Helm CLI version" + required: false runs: using: 'docker' image: 'Dockerfile' @@ -39,5 +39,5 @@ runs: - ${{ inputs.user }} - ${{ inputs.repository }} - ${{ inputs.branch }} - - ${{ inputs.helm_version }} - ${{ inputs.target_dir }} + - ${{ inputs.helm_version }} diff --git a/src/entrypoint.sh b/src/entrypoint.sh index ebed7ae..e4840ef 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -9,8 +9,8 @@ CHARTS_URL=$3 OWNER=$4 REPOSITORY=$5 BRANCH=$6 -HELM_VERSION=$7 -TARGET_DIR=$8 +TARGET_DIR=$7 +HELM_VERSION=$8 CHARTS=() CHARTS_TMP_DIR=$(mktemp -d)