Publish chart index to gh-pages branch (#3)

*Motivation*

Release helm chart when new tags are created
This commit is contained in:
Sijie Guo 2020-04-21 02:44:58 -07:00 committed by GitHub
parent 47f05b7650
commit 0338d17b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 48 additions and 22 deletions

View File

@ -81,9 +81,9 @@ function ci::install_pulsar_chart() {
${CHARTS_HOME}/scripts/pulsar/upload_tls.sh -k ${CLUSTER} -d ${PULSAR_HOME}/.ci/tls ${CHARTS_HOME}/scripts/pulsar/upload_tls.sh -k ${CLUSTER} -d ${PULSAR_HOME}/.ci/tls
sleep 10 sleep 10
echo ${HELM} install --values ${value_file} ${CLUSTER} ${CHARTS_HOME}/pulsar echo ${HELM} install --values ${value_file} ${CLUSTER} ${CHARTS_HOME}/charts/pulsar
${HELM} template --values ${value_file} ${CLUSTER} ${CHARTS_HOME}/pulsar ${HELM} template --values ${value_file} ${CLUSTER} ${CHARTS_HOME}/charts/pulsar
${HELM} install --values ${value_file} ${CLUSTER} ${CHARTS_HOME}/pulsar ${HELM} install --values ${value_file} ${CLUSTER} ${CHARTS_HOME}/charts/pulsar
echo "wait until broker is alive" echo "wait until broker is alive"
WC=$(${KUBECTL} get pods -n ${NAMESPACE} --field-selector=status.phase=Running | grep ${CLUSTER}-broker | wc -l) WC=$(${KUBECTL} get pods -n ${NAMESPACE} --field-selector=status.phase=Running | grep ${CLUSTER}-broker | wc -l)

View File

@ -22,13 +22,10 @@ BINDIR=`dirname "$0"`
CHARTS_HOME=`cd ${BINDIR}/..;pwd` CHARTS_HOME=`cd ${BINDIR}/..;pwd`
CHARTS_PKGS=${CHARTS_HOME}/.chart-packages CHARTS_PKGS=${CHARTS_HOME}/.chart-packages
CHARTS_INDEX=${CHARTS_HOME}/.chart-index CHARTS_INDEX=${CHARTS_HOME}/.chart-index
CHARTS_REPO=${CHARTS_REPO:-"https://charts.streamnative.io"} CHARTS_REPO=${CHARTS_REPO:-"https://pulsar.apache.org/charts/"}
OWNER=${OWNER:-streamnative} OWNER=${OWNER:-apache}
REPO=${REPO:-charts} REPO=${REPO:-pulsar-helm-chart}
GITHUB_TOKEN=${GITHUB_TOKEN:-"UNSET"}
PUBLISH_CHARTS=${PUBLISH_CHARTS:-"false"} PUBLISH_CHARTS=${PUBLISH_CHARTS:-"false"}
GITUSER=${GITUSER:-"UNSET"}
GITEMAIL=${GITEMAIL:-"UNSET"}
# hack/common.sh need this variable to be set # hack/common.sh need this variable to be set
PULSAR_CHART_HOME=${CHARTS_HOME} PULSAR_CHART_HOME=${CHARTS_HOME}
@ -66,17 +63,30 @@ function release::update_chart_index() {
${CR} index -o ${OWNER} -r ${REPO} -t "${GITHUB_TOKEN}" -c ${CHARTS_REPO} --index-path /cr/.chart-index --package-path /cr/.chart-packages ${CR} index -o ${OWNER} -r ${REPO} -t "${GITHUB_TOKEN}" -c ${CHARTS_REPO} --index-path /cr/.chart-index --package-path /cr/.chart-packages
} }
function release::publish_charts() { function release::git_setup() {
git config user.email "${GITEMAIL}" cat <<- EOF > $HOME/.netrc
git config user.name "${GITUSER}" machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config --global user.name "$GITHUB_ACTOR"
}
function release::publish_charts() {
release::git_setup
git remote update
git fetch --all
git checkout gh-pages git checkout gh-pages
cp --force ${CHARTS_INDEX}/index.yaml index.yaml cp --force ${CHARTS_INDEX}/index.yaml index.yaml
git add index.yaml git add index.yaml
git commit --message="Publish new charts to ${CHARTS_REPO}" --signoff git commit --message="Publish new charts to ${CHARTS_REPO}" --signoff
git remote -v git push --set-upstream origin gh-pages
git remote add sn https://${PULSARBOT_USER}:${GITHUB_TOKEN}@github.com/${OWNER}/${REPO}
git push sn gh-pages
} }
# install cr # install cr

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -22,6 +22,8 @@ on:
pull_request: pull_request:
branches: branches:
- '*' - '*'
paths:
- 'charts/pulsar/**'
jobs: jobs:
lint-test: lint-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -23,7 +23,7 @@ on:
branches: branches:
- master - master
jobs: jobs:
lint-test: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -31,11 +31,7 @@ jobs:
- name: Install chart - name: Install chart
env: env:
GITHUB_TOKEN: ${{ secrets.PULSARBOT_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULSARBOT_USER: ${{ secrets.PULSARBOT_USER }} PUBLISH_CHARTS: true
CHARTS_REPO: ${{ secrets.CHARTS_REPO }}
PUBLISH_CHARTS: ${{ secrets.PUBLISH_CHARTS }}
GITUSER: ${{ secrets.GITUSER }}
GITEMAIL: ${{ secrets.GITEMAIL }}
run: | run: |
.ci/release.sh .ci/release.sh