Skip to content

Commit

Permalink
Support packaging and pushing a specified chart only
Browse files Browse the repository at this point in the history
Signed-off-by: Kazuki Suda <[email protected]>
  • Loading branch information
superbrothers committed Dec 10, 2022
1 parent 0ad2bb3 commit c4385b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A GitHub Action for publishing Helm charts with Github Pages.

Inputs:
* `token` The GitHub token with write access to the target repository
* `charts_dir` The charts directory, defaults to `charts`
* `charts_dir` The charts directory, defaults to `charts`. It cannot be used with `chart_dir`.
* `charts_url` The GitHub Pages URL, defaults to `https://<OWNER>.github.io/<REPOSITORY>`
* `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
Expand All @@ -21,6 +21,7 @@ Inputs:
* `index_dir` The location of `index.yaml` file in the repo, defaults to the same value as `target_dir`
* `enterprise_url` The URL of enterprise github server in the format `<server-url>/<organisation>`
* `dependencies` A list of helm repositories required to verify dependencies in the format `<name>,<url>;<name>,<url>` or if using private repositories `<name>,<username>,<password>,<url>;<name>,<username>,<password>,<url>`. Combinations are allowed.
* `chart_dir` The specified chart directory, e.g. charts/wordpress. It cannot be used with `charts_dir`.

## Examples

Expand Down Expand Up @@ -88,3 +89,21 @@ jobs:
app_version: 1.16.0
chart_version: 0.1.0
```
Package and push the specified chart in `./charts/wordpress` dir to `gh-pages` branch:
```yaml
name: release
on:
push:
tags: '*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish Helm charts
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
chart_dir: charts/wordpress
```
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
description: "GitHub token"
required: true
charts_dir:
description: "The charts directory, defaults to `charts`"
description: "The charts directory, defaults to `charts`. It cannot be used with `chart_dir`."
required: false
charts_url:
description: "The GitHub Pages URL, defaults to `https://<OWNER>.github.io/<REPOSITORY>`"
Expand Down Expand Up @@ -55,6 +55,9 @@ inputs:
dependencies:
description: "A list of helm repositories required to verify dependencies in the format '<name>,<url>;<name>,<url>'"
required: false
chart_dir:
description: "The specified chart directory,, e.g. charts/wordpress. It cannot be used with `charts_dir`."
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -75,3 +78,4 @@ runs:
- ${{ inputs.index_dir }}
- ${{ inputs.enterprise_url }}
- ${{ inputs.dependencies }}
- ${{ inputs.chart_dir }}
12 changes: 12 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ CHART_VERSION=${13}
INDEX_DIR=${14}
ENTERPRISE_URL=${15}
DEPENDENCIES=${16}
CHART_DIR=${17}

CHARTS=()
CHARTS_TMP_DIR=$(mktemp -d)
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_URL=""

main() {
if [[ -n "$CHARTS_DIR" ]] && [[ -n "$CHART_DIR" ]]; then
echo '"Both charts_dir" and "chart_dir" cannot be specified' >&2
exit 1
fi

if [[ -z "$HELM_VERSION" ]]; then
HELM_VERSION="3.10.0"
fi
Expand Down Expand Up @@ -104,6 +110,12 @@ main() {
}

locate() {
if [[ -n "$CHART_DIR" ]]; then
echo "Use the specific chart directory ${CHART_DIR}"
CHARTS+=( "$CHART_DIR" )
return
fi

for dir in $(find "${CHARTS_DIR}" -type d -mindepth 1 -maxdepth 1); do
if [[ -f "${dir}/Chart.yaml" ]]; then
CHARTS+=("${dir}")
Expand Down

0 comments on commit c4385b6

Please sign in to comment.