Skip to content

Commit 38cfeac

Browse files
authored
add skip-packaging option (#109)
Signed-off-by: Gary Morse <gmorse81@gmail.com> Signed-off-by: Gary Morse <gmorse81@gmail.com>
1 parent 98bccfd commit 38cfeac

File tree

3 files changed

+51
-26
lines changed

3 files changed

+51
-26
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# *chart-releaser* Action
1+
# _chart-releaser_ Action
22

33
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.
44

@@ -7,18 +7,19 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
77
### Pre-requisites
88

99
1. A GitHub repo containing a directory with your Helm charts (default is a folder named `/charts`, if you want to
10-
maintain your charts in a different directory, you must include a `charts_dir` input in the workflow).
10+
maintain your charts in a different directory, you must include a `charts_dir` input in the workflow).
1111
1. A GitHub branch called `gh-pages` to store the published charts. See `charts_repo_url` for alternatives.
1212
1. In your repo, go to Settings/Pages. Change the `Source` `Branch` to `gh-pages`.
1313
1. Create a workflow `.yml` file in your `.github/workflows` directory. An [example workflow](#example-workflow) is available below.
14-
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)
14+
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)
1515

1616
### Inputs
1717

1818
- `version`: The chart-releaser version to use (default: v1.4.1)
1919
- `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)
2020
- `charts_dir`: The charts directory
2121
- `charts_repo_url`: The GitHub Pages URL to the charts repo (default: `https://<owner>.github.io/<project>`)
22+
- `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.
2223

2324
### Environment variables
2425

@@ -73,6 +74,7 @@ It does this – during every push to `main` – by checking each chart in your
7374
#### Example using custom config
7475

7576
`workflow.yml`:
77+
7678
```yaml
7779
- name: Run chart-releaser
7880
uses: helm/chart-releaser-action@v1.4.1

action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ inputs:
2020
description: "The GitHub Pages URL to the charts repo (default: https://<owner>.github.io/<repo>)"
2121
required: false
2222
install_dir:
23-
description: 'Where to install the cr tool'
23+
description: "Where to install the cr tool"
2424
required: false
2525
install_only:
26-
description: 'Just install cr tool'
26+
description: "Just install cr tool"
27+
required: false
28+
skip_packaging:
29+
description: "skip the packaging option (do your custom packaging before running this action"
2730
required: false
2831

2932
runs:
@@ -61,5 +64,9 @@ runs:
6164
args+=(--install-only "${{ inputs.install_only }}")
6265
fi
6366
67+
if [[ -n "${{ inputs.skip_packaging }}" ]]; then
68+
args+=(--skip-packaging "${{ inputs.skip_packaging }}")
69+
fi
70+
6471
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
6572
shell: bash

cr.sh

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Usage: $(basename "$0") <options>
3333
-r, --repo The repo name
3434
-n, --install-dir The Path to install the cr tool
3535
-i, --install-only Just install the cr tool
36+
-s, --skip-packaging Skip the packaging step (run your own packaging before using the releaser)
3637
EOF
3738
}
3839

@@ -45,6 +46,7 @@ main() {
4546
local charts_repo_url=
4647
local install_dir=
4748
local install_only=
49+
local skip_packaging=
4850

4951
parse_command_line "$@"
5052

@@ -54,35 +56,43 @@ main() {
5456
repo_root=$(git rev-parse --show-toplevel)
5557
pushd "$repo_root" > /dev/null
5658

57-
echo 'Looking up latest tag...'
58-
local latest_tag
59-
latest_tag=$(lookup_latest_tag)
59+
if ! [[ -n "$skip_packaging" ]]; then
60+
echo 'Looking up latest tag...'
61+
local latest_tag
62+
latest_tag=$(lookup_latest_tag)
6063

61-
echo "Discovering changed charts since '$latest_tag'..."
62-
local changed_charts=()
63-
readarray -t changed_charts <<< "$(lookup_changed_charts "$latest_tag")"
64+
echo "Discovering changed charts since '$latest_tag'..."
65+
local changed_charts=()
66+
readarray -t changed_charts <<< "$(lookup_changed_charts "$latest_tag")"
6467

65-
if [[ -n "${changed_charts[*]}" ]]; then
66-
install_chart_releaser
68+
if [[ -n "${changed_charts[*]}" ]]; then
69+
install_chart_releaser
6770

68-
rm -rf .cr-release-packages
69-
mkdir -p .cr-release-packages
71+
rm -rf .cr-release-packages
72+
mkdir -p .cr-release-packages
7073

71-
rm -rf .cr-index
72-
mkdir -p .cr-index
74+
rm -rf .cr-index
75+
mkdir -p .cr-index
7376

74-
for chart in "${changed_charts[@]}"; do
75-
if [[ -d "$chart" ]]; then
76-
package_chart "$chart"
77-
else
78-
echo "Chart '$chart' no longer exists in repo. Skipping it..."
79-
fi
80-
done
77+
for chart in "${changed_charts[@]}"; do
78+
if [[ -d "$chart" ]]; then
79+
package_chart "$chart"
80+
else
81+
echo "Chart '$chart' no longer exists in repo. Skipping it..."
82+
fi
83+
done
8184

85+
release_charts
86+
update_index
87+
else
88+
echo "Nothing to do. No chart changes detected."
89+
fi
90+
else
91+
install_chart_releaser
92+
rm -rf .cr-index
93+
mkdir -p .cr-index
8294
release_charts
8395
update_index
84-
else
85-
echo "Nothing to do. No chart changes detected."
8696
fi
8797

8898
popd > /dev/null
@@ -167,6 +177,12 @@ parse_command_line() {
167177
shift
168178
fi
169179
;;
180+
-s|--skip-packaging)
181+
if [[ -n "${2:-}" ]]; then
182+
skip_packaging="$2"
183+
shift
184+
fi
185+
;;
170186
*)
171187
break
172188
;;

0 commit comments

Comments
 (0)