Skip to content

Commit b9e7efc

Browse files
committed
chore: release to gh-pages
1. our yaml files that specify which image tag to use are now "templated". 2. "template" is replaced in "publish-gh-pages.sh" which runs when "master" is merged, by the latest tag, if it hasn't been published yet. 3. gh-pages branch is updated with all the artifacts required.
1 parent 21183e6 commit b9e7efc

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ node_js:
1616
before_install:
1717
- echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
1818
install:
19+
- git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
20+
- git fetch --unshallow --tags
1921
- npm install
2022
jobs:
2123
include:
@@ -65,7 +67,8 @@ jobs:
6567
./scripts/slack-notify-push.sh ${IMAGE_NAME_PUBLISHED} &&
6668
docker tag ${IMAGE_NAME_APPROVED} snyk/kubernetes-monitor:latest &&
6769
docker push snyk/kubernetes-monitor:latest &&
68-
./scripts/slack-notify-push.sh snyk/kubernetes-monitor:latest ||
70+
./scripts/slack-notify-push.sh snyk/kubernetes-monitor:latest &&
71+
./scripts/publish-gh-pages.sh ${LATEST_TAG} ||
6972
( ./scripts/slack-notify-failure.sh master && false )
7073
name: publish the kubernetes-monitor (npm, container, helm)
7174
branches:

scripts/publish-gh-pages.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /bin/bash
2+
set -e
3+
4+
NEW_TAG=$1
5+
echo About to update the gh-pages branch with new tag ${NEW_TAG}
6+
7+
echo configuring git
8+
git config --global user.email "[email protected]"
9+
git config --global user.name "Runtime CI & CD"
10+
git remote add origin-pages https://${GH_TOKEN}@github.com/snyk/kubernetes-monitor.git > /dev/null 2>&1
11+
git checkout -f gh-pages
12+
13+
if grep -Fxq " tag: ${NEW_TAG}" ./snyk-monitor/values.yaml
14+
then
15+
echo not publishing a new gh-pages commit since this version is already published
16+
./scripts/slack-notify-success-no-publish.sh
17+
exit 0
18+
fi
19+
20+
echo overriding new yaml / chart files from master branch
21+
git checkout origin/chore/publish_gh_pages -- snyk-monitor snyk-monitor-cluster-permissions.yaml snyk-monitor-deployment.yaml snyk-monitor-namespaced-permissions.yaml
22+
23+
echo overriding tag placeholders with latest semantic version
24+
sed -i "s/{{IMAGE_TAG_OVERRIDE_WHEN_PUBLISHING}}/${NEW_TAG}/g" ./snyk-monitor/values.yaml
25+
sed -i "s/{{IMAGE_TAG_OVERRIDE_WHEN_PUBLISHING}}/${NEW_TAG}/g" ./snyk-monitor-deployment.yaml
26+
27+
echo building new helm release
28+
./helm init --client-only
29+
./helm package snyk-monitor --version ${NEW_TAG}
30+
./helm repo index .
31+
32+
echo publishing to gh-pages
33+
git add index.yaml
34+
git add snyk-monitor-${NEW_TAG}.tgz
35+
git add ./snyk-monitor/values.yaml
36+
git add ./snyk-monitor-deployment.yaml
37+
COMMIT_MESSAGE='fix: :egg: Automatic Publish '${NEW_TAG}' :egg:'
38+
git commit -m "${COMMIT_MESSAGE}"
39+
git push --quiet --set-upstream origin-pages gh-pages
40+
./scripts/slack-notify-push.sh "gh-pages"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /bin/bash
2+
curl -X POST -H 'Content-Type:application/json' -d '{"attachments": [{"color": "warning", "fallback": "Build Notification: $TRAVIS_BUILD_WEB_URL", "title": "Kubernetes-Monitor Publish Notification", "text": ":egg_fancy: Successful `master` merge, but no `gh-pages` release occurring :egg_fancy:"}]}' $SLACK_WEBHOOK

snyk-monitor-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
app.kubernetes.io/name: snyk-monitor
1616
spec:
1717
containers:
18-
- image: snyk/kubernetes-monitor:latest
18+
- image: snyk/kubernetes-monitor:{{IMAGE_TAG_OVERRIDE_WHEN_PUBLISHING}}
1919
imagePullPolicy: Always
2020
name: snyk-monitor
2121
terminationMessagePath: /dev/termination-log

snyk-monitor/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ integrationApi: ""
1717
# The registry from which to pull the snyk-monitor image.
1818
image:
1919
repository: snyk/kubernetes-monitor
20-
tag: latest
20+
tag: {{IMAGE_TAG_OVERRIDE_WHEN_PUBLISHING}}
2121
pullPolicy: Always
2222

2323
# The snyk-monitor requires knowing the cluster name so that it can organise

0 commit comments

Comments
 (0)