add skip-packaging option (#109)
Signed-off-by: Gary Morse <gmorse81@gmail.com> Signed-off-by: Gary Morse <gmorse81@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# *chart-releaser* Action
|
# _chart-releaser_ Action
|
||||||
|
|
||||||
A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, using [helm/chart-releaser](https://github.com/helm/chart-releaser) CLI tool.
|
A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, using [helm/chart-releaser](https://github.com/helm/chart-releaser) CLI tool.
|
||||||
|
|
||||||
@@ -7,11 +7,11 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
|
|||||||
### Pre-requisites
|
### Pre-requisites
|
||||||
|
|
||||||
1. A GitHub repo containing a directory with your Helm charts (default is a folder named `/charts`, if you want to
|
1. A GitHub repo containing a directory with your Helm charts (default is a folder named `/charts`, if you want to
|
||||||
maintain your charts in a different directory, you must include a `charts_dir` input in the workflow).
|
maintain your charts in a different directory, you must include a `charts_dir` input in the workflow).
|
||||||
1. A GitHub branch called `gh-pages` to store the published charts. See `charts_repo_url` for alternatives.
|
1. A GitHub branch called `gh-pages` to store the published charts. See `charts_repo_url` for alternatives.
|
||||||
1. In your repo, go to Settings/Pages. Change the `Source` `Branch` to `gh-pages`.
|
1. In your repo, go to Settings/Pages. Change the `Source` `Branch` to `gh-pages`.
|
||||||
1. Create a workflow `.yml` file in your `.github/workflows` directory. An [example workflow](#example-workflow) is available below.
|
1. Create a workflow `.yml` file in your `.github/workflows` directory. An [example workflow](#example-workflow) is available below.
|
||||||
For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)
|
For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)
|
||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ maintain your charts in a different directory, you must include a `charts_dir` i
|
|||||||
- `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)
|
- `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_dir`: The charts directory
|
||||||
- `charts_repo_url`: The GitHub Pages URL to the charts repo (default: `https://<owner>.github.io/<project>`)
|
- `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.
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ It does this – during every push to `main` – by checking each chart in your
|
|||||||
#### Example using custom config
|
#### Example using custom config
|
||||||
|
|
||||||
`workflow.yml`:
|
`workflow.yml`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Run chart-releaser
|
- name: Run chart-releaser
|
||||||
uses: helm/chart-releaser-action@v1.4.1
|
uses: helm/chart-releaser-action@v1.4.1
|
||||||
|
|||||||
+9
-2
@@ -20,10 +20,13 @@ inputs:
|
|||||||
description: "The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)"
|
description: "The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)"
|
||||||
required: false
|
required: false
|
||||||
install_dir:
|
install_dir:
|
||||||
description: 'Where to install the cr tool'
|
description: "Where to install the cr tool"
|
||||||
required: false
|
required: false
|
||||||
install_only:
|
install_only:
|
||||||
description: 'Just install cr tool'
|
description: "Just install cr tool"
|
||||||
|
required: false
|
||||||
|
skip_packaging:
|
||||||
|
description: "skip the packaging option (do your custom packaging before running this action"
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
@@ -61,5 +64,9 @@ runs:
|
|||||||
args+=(--install-only "${{ inputs.install_only }}")
|
args+=(--install-only "${{ inputs.install_only }}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${{ inputs.skip_packaging }}" ]]; then
|
||||||
|
args+=(--skip-packaging "${{ inputs.skip_packaging }}")
|
||||||
|
fi
|
||||||
|
|
||||||
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
|
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Usage: $(basename "$0") <options>
|
|||||||
-r, --repo The repo name
|
-r, --repo The repo name
|
||||||
-n, --install-dir The Path to install the cr tool
|
-n, --install-dir The Path to install the cr tool
|
||||||
-i, --install-only Just 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)
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ main() {
|
|||||||
local charts_repo_url=
|
local charts_repo_url=
|
||||||
local install_dir=
|
local install_dir=
|
||||||
local install_only=
|
local install_only=
|
||||||
|
local skip_packaging=
|
||||||
|
|
||||||
parse_command_line "$@"
|
parse_command_line "$@"
|
||||||
|
|
||||||
@@ -54,35 +56,43 @@ main() {
|
|||||||
repo_root=$(git rev-parse --show-toplevel)
|
repo_root=$(git rev-parse --show-toplevel)
|
||||||
pushd "$repo_root" > /dev/null
|
pushd "$repo_root" > /dev/null
|
||||||
|
|
||||||
echo 'Looking up latest tag...'
|
if ! [[ -n "$skip_packaging" ]]; then
|
||||||
local latest_tag
|
echo 'Looking up latest tag...'
|
||||||
latest_tag=$(lookup_latest_tag)
|
local latest_tag
|
||||||
|
latest_tag=$(lookup_latest_tag)
|
||||||
|
|
||||||
echo "Discovering changed charts since '$latest_tag'..."
|
echo "Discovering changed charts since '$latest_tag'..."
|
||||||
local changed_charts=()
|
local changed_charts=()
|
||||||
readarray -t changed_charts <<< "$(lookup_changed_charts "$latest_tag")"
|
readarray -t changed_charts <<< "$(lookup_changed_charts "$latest_tag")"
|
||||||
|
|
||||||
if [[ -n "${changed_charts[*]}" ]]; then
|
if [[ -n "${changed_charts[*]}" ]]; then
|
||||||
|
install_chart_releaser
|
||||||
|
|
||||||
|
rm -rf .cr-release-packages
|
||||||
|
mkdir -p .cr-release-packages
|
||||||
|
|
||||||
|
rm -rf .cr-index
|
||||||
|
mkdir -p .cr-index
|
||||||
|
|
||||||
|
for chart in "${changed_charts[@]}"; do
|
||||||
|
if [[ -d "$chart" ]]; then
|
||||||
|
package_chart "$chart"
|
||||||
|
else
|
||||||
|
echo "Chart '$chart' no longer exists in repo. Skipping it..."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
release_charts
|
||||||
|
update_index
|
||||||
|
else
|
||||||
|
echo "Nothing to do. No chart changes detected."
|
||||||
|
fi
|
||||||
|
else
|
||||||
install_chart_releaser
|
install_chart_releaser
|
||||||
|
|
||||||
rm -rf .cr-release-packages
|
|
||||||
mkdir -p .cr-release-packages
|
|
||||||
|
|
||||||
rm -rf .cr-index
|
rm -rf .cr-index
|
||||||
mkdir -p .cr-index
|
mkdir -p .cr-index
|
||||||
|
|
||||||
for chart in "${changed_charts[@]}"; do
|
|
||||||
if [[ -d "$chart" ]]; then
|
|
||||||
package_chart "$chart"
|
|
||||||
else
|
|
||||||
echo "Chart '$chart' no longer exists in repo. Skipping it..."
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
release_charts
|
release_charts
|
||||||
update_index
|
update_index
|
||||||
else
|
|
||||||
echo "Nothing to do. No chart changes detected."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
@@ -167,6 +177,12 @@ parse_command_line() {
|
|||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
-s|--skip-packaging)
|
||||||
|
if [[ -n "${2:-}" ]]; then
|
||||||
|
skip_packaging="$2"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user