Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ryu-sato/imprv/auto-publish-charts-in-gh-p…
…ages-branch Imprv/auto publish charts in gh pages branch
- Loading branch information
Showing
6 changed files
with
278 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash -e | ||
|
||
# ================================================================================ | ||
# Update helm repository that published by GitHub Page | ||
# | ||
# <Environments> | ||
# | ||
# HELM_VERSION ... Helm version which will be installed. (default: "2.16.3") | ||
# ================================================================================ | ||
set -o pipefail | ||
|
||
HELM_VERSION="${HELM_VERSION:-2.16.3}" | ||
|
||
INSTALL_DIR="/usr/local/bin" | ||
if [ -f "${INSTALL_DIR}/helm" ]; then | ||
echo "[DEBUG] helm is already installed." | ||
helm version --client | ||
fi | ||
|
||
# ref. https://helm.sh/docs/intro/install/#from-the-binary-releases | ||
pushd $(mktemp -d) | ||
curl -sSL https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz | tar xz | ||
sudo mv linux-amd64/helm "${INSTALL_DIR}"/helm | ||
rm -rf linux-amd64 | ||
popd | ||
|
||
helm version --client |
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,33 @@ | ||
#!/bin/bash -e | ||
|
||
# ================================================================================ | ||
# Update the helm repository on GitHub Pages | ||
# | ||
# <Environments> | ||
# | ||
# SRC_CHARTS_PATH_BASE ... base path where charts are (default: "charts") | ||
# GH_PAGES_BRANCH ... branch name for GitHub Page. (default: "gh-pages") | ||
# ================================================================================ | ||
|
||
SRC_CHARTS_PATH_BASE=${SRC_CHARTS_PATH_BASE:-charts} | ||
GH_PAGES_BRANCH=${GH_PAGES_BRANCH:-gh-pages} | ||
|
||
# Initialize working directory | ||
GH_PAGES_WORKTREE="$(mktemp -d)" | ||
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* | ||
git worktree add "${GH_PAGES_WORKTREE}" ${GH_PAGES_BRANCH} | ||
|
||
# Create helm packages | ||
helm init --client-only | ||
helm package "${SRC_CHARTS_PATH_BASE}"/* --destination "${GH_PAGES_WORKTREE}" --dependency-update --save=false | ||
|
||
# Update helm repo index | ||
# (ref. https://github.com/helm/chart-releaser-action/blob/5ecd0f7f1ac8eb35a24baa68eaf39ed0f08325ac/cr.sh#L212-L234) | ||
pushd "${GH_PAGES_WORKTREE}" | ||
helm repo index . | ||
git add . | ||
git diff # debug info | ||
git commit -m "Update helm packages" | ||
git push origin ${GH_PAGES_BRANCH} | ||
popd | ||
git worktree remove "${GH_PAGES_WORKTREE}" |
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,52 @@ | ||
name: Release Valid Charts | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
env: | ||
SRC_CHARTS_PATH_BASE: charts | ||
ENABLE_INSTALL_TEST: false | ||
|
||
jobs: | ||
lint_and_install: | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install helm | ||
run: | | ||
${GITHUB_WORKSPACE}/.github/scripts/install-helm.sh | ||
- name: Lint charts | ||
run: | | ||
helm init --client-only | ||
helm lint "${SRC_CHARTS_PATH_BASE}"/* | ||
- name: Install charts and run each chart's test | ||
if: env.ENABLE_INSTALL_TEST == 'true' | ||
run: | | ||
${GITHUB_WORKSPACE}/misc/exec-helm-test.sh --config "${GITHUB_WORKSPACE}/misc/kind-config.yaml" --chartdir "${SRC_CHARTS_PATH_BASE}" | ||
release: | ||
runs-on: ubuntu-18.04 | ||
needs: lint_and_install | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Install helm | ||
run: | | ||
${GITHUB_WORKSPACE}/.github/scripts/install-helm.sh | ||
- name: Update the helm repository on GitHub Pages | ||
run: | | ||
${GITHUB_WORKSPACE}/.github/scripts/update-repository.sh |
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 |
---|---|---|
@@ -1 +1,15 @@ | ||
# WESEEK Helm Charts | ||
|
||
GitHub Pages are used as a Helm Charts repository. | ||
|
||
You can add this helm repository by follows. | ||
|
||
```bash | ||
$ helm repo add weseek https://weseek.github.io/helm-charts/ | ||
``` | ||
|
||
If you want to download helm package manually, see [gh-pages branch](https://github.com/weseek/helm-charts/tree/gh-pages). | ||
|
||
|Name | | ||
| --------------------- | | ||
|[GROWI](./charts/growi)| |
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,144 @@ | ||
#!/bin/bash -e | ||
|
||
# ================================================================================ | ||
# Create kind cluster and execute "helm test" | ||
# | ||
# <What you need to execute> | ||
# | ||
# `kubectl`, `helm` command | ||
# ================================================================================ | ||
|
||
show_help_with_exit() { | ||
cat << EOF | ||
Usage: $(basename "$0") [OPTION]... | ||
Create kind cluster and execute "helm test". | ||
Mandatory arguments to long options are mandatory for short options too. | ||
-h, --help Display help | ||
--debug Display verbose output | ||
-c, --chartdir=DIRPATH Base path where charts are (default: "charts") | ||
--kindver=VERSION "kind" version (default: "0.7.0") | ||
-t, --timeout=SECONDS Timeout of "helm install" command (default: "600") | ||
-f, --config=CONFPATH Config file path | ||
EOF | ||
|
||
exit 1 | ||
} | ||
|
||
main() { | ||
# -------------------------------------------------------------------------------- | ||
# Get parameters | ||
# (ref. https://github.com/helm/chart-releaser-action/blob/5ecd0f7f1ac8eb35a24baa68eaf39ed0f08325ac/cr.sh) | ||
# -------------------------------------------------------------------------------- | ||
|
||
local debug= | ||
local chartdir=charts | ||
local kindver=0.7.0 | ||
local timeout=600 | ||
local config= | ||
|
||
while :; do | ||
case "${1:-}" in | ||
-h|--help) | ||
show_help_with_exit | ||
;; | ||
--debug) | ||
debug=true | ||
;; | ||
-c|--chartdir) | ||
if [[ -n "${2:-}" ]]; then | ||
chartdir="$2" | ||
shift | ||
else | ||
echo "ERROR: '--chart' cannot be empty." >&2 | ||
show_help_with_exit | ||
fi | ||
;; | ||
--kindver) | ||
if [[ -n "${2:-}" ]]; then | ||
kindver="$2" | ||
shift | ||
else | ||
echo "ERROR: '--kindver' cannot be empty." >&2 | ||
show_help_with_exit | ||
fi | ||
;; | ||
-t|--timeout) | ||
if [[ -n "${2:-}" ]]; then | ||
timeout="$2" | ||
shift | ||
else | ||
echo "ERROR: '--timeout' cannot be empty." >&2 | ||
show_help_with_exit | ||
fi | ||
;; | ||
-f|--config) | ||
if [[ -n "${2:-}" ]]; then | ||
config="$2" | ||
shift | ||
else | ||
echo "ERROR: '--config' cannot be empty." >&2 | ||
show_help_with_exit | ||
fi | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
|
||
shift | ||
done | ||
|
||
[ -n "$config" ] && KIND_CONFIG_OPT="--config ${config}" || KIND_CONFIG_OPT="" | ||
[ -n "$debug" ] && KIND_VERBOSE_OPT="-v 10" || KIND_VERBOSE_OPT="" | ||
[ -n "$debug" ] && KUBECTL_VERBOSE_OPT="-v 10" || KUBECTL_VERBOSE_OPT="" | ||
[ -n "$debug" ] && HELM_DEBUG_OPT="--debug" || HELM_DEBUG_OPT="" | ||
|
||
# -------------------------------------------------------------------------------- | ||
# Create kind cluster and execute "helm test" | ||
# -------------------------------------------------------------------------------- | ||
|
||
# Install `kind` if it doesn't exist | ||
KIND=$(which kind) || true | ||
if [ -z "${KIND}" ]; then | ||
echo "Installing kind..." | ||
|
||
TMP_KIND_DIR=$(mktemp -d) | ||
trap "rm -rfv ${TMP_KIND_DIR}" EXIT | ||
|
||
pushd ${TMP_KIND_DIR} | ||
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v${kindver}/kind-$(uname)-amd64 | ||
chmod +x kind | ||
popd | ||
|
||
KIND="${TMP_KIND_DIR}/kind" | ||
fi | ||
|
||
CLUSTER_NAME="exec-helm-test-$RANDOM" | ||
${KIND} create cluster --name ${CLUSTER_NAME} ${KIND_VERBOSE_OPT} ${KIND_CONFIG_OPT} | ||
|
||
# Initialize helm with tiller | ||
kubectl create serviceaccount --namespace kube-system tiller ${KUBECTL_VERBOSE_OPT} | ||
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller ${KUBECTL_VERBOSE_OPT} | ||
helm init --wait --service-account tiller ${HELM_DEBUG_OPT} | ||
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' ${KUBECTL_VERBOSE_OPT} | ||
helm version --server ${HELM_DEBUG_OPT} | ||
|
||
# -------------------------------------------------------------------------------- | ||
# Install helm and run chart's test | ||
# -------------------------------------------------------------------------------- | ||
|
||
pushd "${chartdir}" | ||
|
||
for CHART in $(ls -d *); do | ||
helm install --dep-up --wait --timeout ${timeout} -n ${CHART} ${HELM_DEBUG_OPT} ${CHART} | ||
helm test ${HELM_DEBUG_OPT} ${CHART} | ||
helm delete --purge ${HELM_DEBUG_OPT} ${CHART} | ||
done | ||
|
||
popd | ||
|
||
${KIND} delete cluster --name ${CLUSTER_NAME} | ||
} | ||
|
||
main "$@" |
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,8 @@ | ||
# ref. https://kind.sigs.k8s.io/docs/user/configuration/ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
- role: worker | ||
- role: worker |