This repository has been archived by the owner on Mar 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add release steps to serve Helm Charts Repository on Github Pages (#183)
Co-authored-by: Aliaksei Kozich <[email protected]>
- Loading branch information
Showing
4 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
|
||
cd $DIR/.. | ||
|
||
REMOTE_URL_BASE=$1 | ||
REMOTE_INDEX_URL=$2 | ||
CHARTS_DIR=".helm-release-packages" | ||
|
||
EXISTING_INDEX=$(mktemp /tmp/index.yaml.XXXXXX) | ||
|
||
REMOTE_CODE=$(curl -s -L -w "%{http_code}" $REMOTE_INDEX_URL -o $EXISTING_INDEX) | ||
if [ $REMOTE_CODE -eq 200 ]; then | ||
echo Adding new packages to existing index | ||
helm repo index --merge $EXISTING_INDEX --url $REMOTE_URL_BASE CHARTS_DIR | ||
else | ||
echo Creating new index | ||
helm repo index --url $REMOTE_URL_BASE $CHARTS_DIR | ||
fi | ||
|
||
rm "${EXISTING_INDEX}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
|
||
cd $DIR/.. | ||
|
||
CHARTS_DIR=".helm-release-packages" | ||
GITHUB_PAGES_BRANCH="gh-pages" | ||
|
||
function pages_branch_missing() { | ||
local existed_in_remote=$(git ls-remote --heads origin $GITHUB_PAGES_BRANCH) | ||
|
||
[ -z "${existed_in_remote}" ] | ||
} | ||
|
||
function create_pages_branch() { | ||
echo "Creating pages branch ${GITHUB_PAGES_BRANCH}" | ||
git checkout --quiet --orphan $GITHUB_PAGES_BRANCH | ||
git rm --quiet -rf . | ||
git commit --quiet --allow-empty -m "Pages initial commit" | ||
git push --quiet origin HEAD:refs/heads/$GITHUB_PAGES_BRANCH | ||
git checkout --detach --quiet | ||
git branch --quiet -d $GITHUB_PAGES_BRANCH | ||
} | ||
|
||
function add_pages_worktree() { | ||
local worktree_dir=${1} | ||
|
||
if pages_branch_missing; then | ||
git worktree add --quiet --detach ${worktree_dir} | ||
pushd ${worktree_dir} > /dev/null | ||
create_pages_branch | ||
popd > /dev/null | ||
else | ||
git worktree add --quiet ${worktree_dir} "origin/${GITHUB_PAGES_BRANCH}" | ||
fi | ||
} | ||
|
||
function remove_pages_worktree() { | ||
local worktree_dir=${1} | ||
git worktree remove --force ${worktree_dir} | ||
rm -rf ${worktree_dir} | ||
} | ||
|
||
function push_index() { | ||
if [[ ! -f "${CHARTS_DIR}/index.yaml" ]]; then | ||
return -1 | ||
fi | ||
|
||
local worktree=$(mktemp -d /tmp/worktree.XXXXXX) | ||
add_pages_worktree ${worktree} | ||
|
||
cp ${CHARTS_DIR}/index.yaml ${worktree}/ | ||
pushd ${worktree} > /dev/null | ||
git add index.yaml | ||
git commit --quiet --message "Update index.yaml" | ||
git push --quiet origin HEAD:refs/heads/$GITHUB_PAGES_BRANCH | ||
popd > /dev/null | ||
|
||
remove_pages_worktree ${worktree} | ||
} | ||
|
||
push_index | ||
|
||
|