Skip to content

Commit

Permalink
Remove charts_repo_url from readme (helm#144)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
viceice authored and jjssn committed Jul 5, 2023
1 parent fdfc0aa commit 9c0a3b5
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 13 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
- `version`: The chart-releaser version to use (default: v1.4.1)
- `config`: Optional config file for chart-releaser. For more information on the config file, see the [documentation](https://github.com/helm/chart-releaser#config-file)
- `charts_dir`: The charts directory
- `charts_repo_url`: The GitHub Pages URL to the charts repo (default: `https://<owner>.github.io/<project>`)
- `skip_packaging`: This option, when populated, will skip the packaging step. This allows you to do more advanced packaging of your charts (for example, with the `helm package` command) before this action runs. This action will only handle the indexing and publishing steps.
- `mark_as_latest`: When you set this to `false`, it will mark the created GitHub release not as 'latest'.

Expand Down Expand Up @@ -80,7 +79,6 @@ It does this – during every push to `main` – by checking each chart in your
with:
charts_dir: charts
config: cr.yaml
charts_repo_url: xxxxxx
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
```
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ inputs:
description: Mark the created GitHub release as 'latest'
required: false
default: true
distribute_charts:
description: "Push charts to a remote registry (OCI)"
required: false
default: false

runs:
using: composite
Expand Down Expand Up @@ -76,5 +80,9 @@ runs:
args+=(--mark-as-latest "${{ inputs.mark_as_latest }}")
fi
if [[ -n "${{ inputs.distribute_charts }}" ]]; then
args+=(--distribute-charts "${{ inputs.distribute_charts }}")
fi
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
shell: bash
65 changes: 54 additions & 11 deletions cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ show_help() {
cat << EOF
Usage: $(basename "$0") <options>
-h, --help Display help
-v, --version The chart-releaser version to use (default: $DEFAULT_CHART_RELEASER_VERSION)"
--config The path to the chart-releaser config file
-d, --charts-dir The charts directory (default: charts)
-o, --owner The repo owner
-r, --repo The repo name
-n, --install-dir The Path to install the cr tool
-i, --install-only Just install the cr tool
-s, --skip-packaging Skip the packaging step (run your own packaging before using the releaser)
--skip-existing Skip package upload if release exists
-l, --mark-as-latest Mark the created GitHub release as 'latest' (default: true)
-h, --help Display help
-v, --version The chart-releaser version to use (default: $DEFAULT_CHART_RELEASER_VERSION)"
--config The path to the chart-releaser config file
-d, --charts-dir The charts directory (default: charts)
-o, --owner The repo owner
-r, --repo The repo name
-n, --install-dir The Path to install the cr tool
-i, --install-only Just install the cr tool
-s, --skip-packaging Skip the packaging step (run your own packaging before using the releaser)
--skip-existing Skip package upload if release exists
-l, --mark-as-latest Mark the created GitHub release as 'latest' (default: true)
--distribute-charts Push charts to a remote registry (OCI)
EOF
}

Expand All @@ -49,6 +50,7 @@ main() {
local skip_packaging=
local skip_existing=
local mark_as_latest=true
local distribute_charts=

parse_command_line "$@"

Expand Down Expand Up @@ -76,9 +78,14 @@ main() {
rm -rf .cr-index
mkdir -p .cr-index

if [[ $distribute_charts ]]; then
remote_registry_login
fi

for chart in "${changed_charts[@]}"; do
if [[ -d "$chart" ]]; then
package_chart "$chart"
remote_registry_push "$chart"
else
echo "Chart '$chart' no longer exists in repo. Skipping it..."
fi
Expand Down Expand Up @@ -187,6 +194,12 @@ parse_command_line() {
shift
fi
;;
--distribute-charts)
if [[ -n "${2:-}" ]]; then
distribute_charts="$2"
shift
fi
;;
*)
break
;;
Expand Down Expand Up @@ -218,6 +231,15 @@ parse_command_line() {
install_chart_releaser
exit 0
fi

if [[ -n "$distribute_charts" ]]; then
echo "Will connect to remote registry with environment variables 'REMOTE_REGISTRY_URL', 'REMOTE_REGISTRY_USERNAME', 'REMOTE_REGISTRY_PASSWORD'"
[[ -n "${REMOTE_REGISTRY_URL:?Error: Environment variable REMOTE_REGISTRY_URL must be set}" ]] || exit 1
REMOTE_REGISTRY_URL="${REMOTE_REGISTRY_URL#*://}"
[[ -n "${REMOTE_REGISTRY_USERNAME:?Error: Environment variable REMOTE_REGISTRY_USERNAME must be set}" ]] || exit 1
[[ -n "${REMOTE_REGISTRY_PASSWORD:?Error: Environment variable REMOTE_REGISTRY_PASSWORD must be set}" ]] || exit 1
remote_registry_login
fi
}

install_chart_releaser() {
Expand Down Expand Up @@ -308,5 +330,26 @@ update_index() {
echo 'Updating charts repo index...'
cr index "${args[@]}"
}
remote_registry_login() {
echo "Logging in to the remote registry '$REMOTE_REGISTRY_URL'..."
if helm registry login "$REMOTE_REGISTRY_URL" --username "$REMOTE_REGISTRY_USERNAME " --password "$REMOTE_REGISTRY_PASSWORD"; then
echo "Login to the remote registry successful."
else
echo "Failed to login to the remote registry."
exit 1
fi
}
remote_registry_push() {
local chart="$1"
local registry_url="$REMOTE_REGISTRY_URL"
local chart_file=$(ls $(pwd)/.cr-release-packages/$(basename "$chart")-*.tgz)

if [[ ! -e $chart_file ]]; then
echo "ERROR: Chart file '$chart_file' not found." >&2
exit 1
fi

echo "Pushing chart '$chart_file' to remote registry oci://'$registry_url'/helm..."
helm push "$chart_file" "oci://$registry_url/helm"
}
main "$@"

0 comments on commit 9c0a3b5

Please sign in to comment.