Skip to content

Commit 76ba73d

Browse files
authored
Merge pull request #8 from steven-sheehy/target-dir
Add support for storing charts in sub-folder
2 parents a6d2694 + bc6fa4a commit 76ba73d

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Inputs:
1111
* `owner` The GitHub user or org that owns this repository, defaults to the owner in `GITHUB_REPOSITORY` env var
1212
* `repository` The GitHub repository, defaults to the `GITHUB_REPOSITORY` env var
1313
* `branch` The branch to publish charts, defaults to `gh-pages`
14+
* `target_dir` The target directory to store the charts, defaults to `.`
1415
* `helm_version` The Helm CLI version, defaults to the latest release
1516

1617
## Examples
@@ -56,4 +57,5 @@ jobs:
5657
owner: fluxcd
5758
repository: charts
5859
branch: gh-pages
60+
target_dir: charts
5961
```

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
branch:
2424
description: "The branch to publish charts, defaults to `gh-pages`"
2525
required: false
26+
target_dir:
27+
description: "The target directory to store the charts, defaults to `.`"
28+
required: false
2629
helm_version:
2730
description: "The Helm CLI version"
2831
required: false
@@ -36,4 +39,5 @@ runs:
3639
- ${{ inputs.user }}
3740
- ${{ inputs.repository }}
3841
- ${{ inputs.branch }}
39-
- ${{ inputs.helm_version }}
42+
- ${{ inputs.target_dir }}
43+
- ${{ inputs.helm_version }}

src/entrypoint.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ CHARTS_URL=$3
99
OWNER=$4
1010
REPOSITORY=$5
1111
BRANCH=$6
12-
HELM_VERSION=$7
12+
TARGET_DIR=$7
13+
HELM_VERSION=$8
1314

1415
CHARTS=()
1516
CHARTS_TMP_DIR=$(mktemp -d)
@@ -37,10 +38,18 @@ main() {
3738
BRANCH="gh-pages"
3839
fi
3940

41+
if [[ -z "$TARGET_DIR" ]]; then
42+
TARGET_DIR="."
43+
fi
44+
4045
if [[ -z "$CHARTS_URL" ]]; then
4146
CHARTS_URL="https://${OWNER}.github.io/${REPOSITORY}"
4247
fi
4348

49+
if [[ "$TARGET_DIR" != "." ]]; then
50+
CHARTS_URL="${CHARTS_URL}/${TARGET_DIR}"
51+
fi
52+
4453
if [[ -z "$REPO_URL" ]]; then
4554
REPO_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${OWNER}/${REPOSITORY}"
4655
fi
@@ -103,10 +112,11 @@ upload() {
103112

104113
charts=$(cd ${CHARTS_TMP_DIR} && ls *.tgz | xargs)
105114

106-
mv -f ${CHARTS_TMP_DIR}/*.tgz .
107-
helm repo index . --url ${CHARTS_URL}
115+
mkdir -p ${TARGET_DIR}
116+
mv -f ${CHARTS_TMP_DIR}/*.tgz ${TARGET_DIR}
117+
helm repo index ${TARGET_DIR} --url ${CHARTS_URL}
108118

109-
git add .
119+
git add ${TARGET_DIR}
110120
git commit -m "Publish $charts"
111121
git push origin gh-pages
112122

0 commit comments

Comments
 (0)