From a8736e51af2fbecb48e1ddbb864122f24e326811 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 29 Mar 2024 17:18:02 +0800 Subject: [PATCH 1/2] feat(index-path): added inputs for index-path and pages-index-path Signed-off-by: yuyi --- README.md | 2 ++ action.yml | 14 ++++++++++++++ cr.sh | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/README.md b/README.md index 7b06e14..2939499 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi - `mark_as_latest`: When you set this to `false`, it will mark the created GitHub release not as 'latest'. - `packages_with_index`: When you set this to `true`, it will upload chart packages directly into publishing branch. - `pages_branch`: Name of the branch to be used to push the index and artifacts. (default to: gh-pages but it is not set in the action it is a default value for the chart-releaser binary) +- `pages_index_path`: Path to the index file in the gh-pages branch. (default to: index.yaml but it is not set in the action) +- `index_path`: Path to the index file. (default to: .cr-index/index.yaml but it is not set in the action) ### Outputs diff --git a/action.yml b/action.yml index b75c1dc..52ae9c2 100644 --- a/action.yml +++ b/action.yml @@ -56,6 +56,12 @@ inputs: pages_branch: description: "Name of the branch to be used to push the index and artifacts. (default to: gh-pages but it is not set in the action it is a default value for the chart-releaser binary)" required: false + pages_index_path: + description: "The GitHub pages index path. (default to: index.yaml but it is not set in the action)" + required: false + index_path: + description: "Path to index file. (default to: .cr-index/index.yaml but it is not set in the action)" + required: false outputs: changed_charts: description: "A comma-separated list of charts that were released on this run. Will be an empty string if no updates were detected, will be unset if `--skip_packaging` is used: in the latter case your custom packaging step is responsible for setting its own outputs if you need them." @@ -120,6 +126,14 @@ runs: args+=(--pages-branch "${{ inputs.pages_branch }}") fi + if [[ -n "${{ inputs.pages_index_path }}" ]]; then + args+=(--pages-index-path "${{ inputs.pages_index_path }}") + fi + + if [[ -n "${{ inputs.index_path }}" ]]; then + args+=(--index-path "${{ inputs.index_path }}") + fi + "$GITHUB_ACTION_PATH/cr.sh" "${args[@]}" if [[ -f changed_charts.txt ]]; then diff --git a/cr.sh b/cr.sh index 4897b65..88d7b75 100755 --- a/cr.sh +++ b/cr.sh @@ -55,6 +55,8 @@ main() { local mark_as_latest=true local packages_with_index=false local pages_branch= + local index_path= + local pages_index_path= parse_command_line "$@" @@ -176,6 +178,18 @@ parse_command_line() { shift fi ;; + --index-path) + if [[ -n "${2:-}" ]]; then + index_path="$2" + shift + fi + ;; + --pages-index-path) + if [[ -n "${2:-}" ]]; then + pages_index_path="$2" + shift + fi + ;; -n | --install-dir) if [[ -n "${2:-}" ]]; then install_dir="$2" @@ -351,6 +365,12 @@ update_index() { if [[ -n "$pages_branch" ]]; then args+=(--pages-branch "$pages_branch") fi + if [[ -n "$index_path" ]]; then + args+=(--index-path "$index_path") + fi + if [[ -n "$pages_index_path" ]]; then + args+=(--pages-index-path "$pages_index_path") + fi echo 'Updating charts repo index...' cr index "${args[@]}" From c652346b66bb97876c06a593957da99a97c8d1d9 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 29 Mar 2024 17:45:01 +0800 Subject: [PATCH 2/2] chore(help): added help message for index-path and pages-index-path Signed-off-by: yuyi --- cr.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cr.sh b/cr.sh index 88d7b75..e4abfb0 100755 --- a/cr.sh +++ b/cr.sh @@ -38,6 +38,8 @@ Usage: $(basename "$0") --skip-upload Skip package upload, just create the release. Not needed in case of OCI upload. -l, --mark-as-latest Mark the created GitHub release as 'latest' (default: true) --packages-with-index Upload chart packages directly into publishing branch + --index-path The path to the index file + --pages-index-path The path to the index file in the pages branch EOF }