-
Notifications
You must be signed in to change notification settings - Fork 816
/
Copy pathpublish
executable file
·51 lines (45 loc) · 2.46 KB
/
publish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# This script publishes the Helm chart to the JupyterHub Helm chart repo and
# pushes associated built docker images to Docker hub using chartpress.
# --------------------------------------------------------------------------
# Exit on errors, assert env vars, log commands
set -eux
PUBLISH_ARGS="--push \
--builder docker-buildx \
--platform linux/amd64 --platform linux/arm64 \
"
# chartpress use git to push to our Helm chart repository, which is the gh-pages
# branch of jupyterhub/helm-chart. We have installed a private SSH key within
# the ~/.ssh folder with permissions to push to jupyterhub/helm-chart.
if [[ $GITHUB_REF != refs/tags/* ]]; then
# Using --extra-message, we help readers of merged PRs to know what version
# they need to bump to in order to make use of the PR. This is enabled by a
# GitHub notificaiton in the PR like "Github Action user pushed a commit to
# jupyterhub/helm-chart that referenced this pull request..."
#
# ref: https://github.com/jupyterhub/chartpress#usage
#
# NOTE: GitHub merge commits contain a PR reference like #123. `sed` looks
# to extract either a PR reference like #123 or fall back to create a
# commit hash reference like @123abcd. Combined with GITHUB_REPOSITORY
# we craft a commit message like jupyterhub/zero-to-jupyterhub-k8s#123
# or jupyterhub/zero-to-jupyterhub-k8s@123abcd which will be
# understood as a reference by GitHub.
PR_OR_HASH=$(git log -1 --pretty=%h-%B | head -n1 | sed 's/^.*\(#[0-9]*\).*/\1/' | sed 's/^\([0-9a-f]*\)-.*/@\1/')
LATEST_COMMIT_TITLE=$(git log -1 --pretty=%B | head -n1)
EXTRA_MESSAGE="${GITHUB_REPOSITORY}${PR_OR_HASH} ${LATEST_COMMIT_TITLE}"
# shellcheck disable=SC2086
chartpress $PUBLISH_ARGS --extra-message "${EXTRA_MESSAGE}" --publish-chart
# shellcheck disable=SC2086
chartpress $PUBLISH_ARGS --extra-message "${EXTRA_MESSAGE}" --image-prefix=jupyterhub/k8s-
else
# Setting a tag explicitly enforces a rebuild if this tag had already been
# built and we wanted to override it.
# shellcheck disable=SC2086
chartpress $PUBLISH_ARGS --tag "${GITHUB_REF:10}" --publish-chart
# shellcheck disable=SC2086
chartpress $PUBLISH_ARGS --tag "${GITHUB_REF:10}" --image-prefix=jupyterhub/k8s-
fi
# Let us log the changes chartpress did, it should include replacements for
# fields in values.yaml, such as what tag for various images we are using.
git --no-pager diff --color