Skip to content

Commit 5960b8d

Browse files
[ONPREM-2020] Push Helm chart to Packagecloud repo (#19)
* Add publish-chart job * Update chart version to indicate it's a development version * Start publishing the Helm chart to Packagecloud * Notify Slack of publishing * Gate publishing to main
1 parent d807d9b commit 5960b8d

File tree

3 files changed

+115
-9
lines changed

3 files changed

+115
-9
lines changed

.circleci/config.yml

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,21 @@ workflows:
1818
main-workflow:
1919
jobs:
2020
- lint
21-
- test
21+
- unit-tests
2222
- docs
2323
- package-chart:
24+
requires: [lint, unit-tests, docs]
2425
context: runner-signing
2526
- smoke-tests
27+
- approve-deploy-chart:
28+
type: approval
29+
filters:
30+
branches:
31+
only: main
32+
requires: [package-chart, smoke-tests]
33+
- deploy-chart:
34+
requires: [approve-deploy-chart]
35+
context: runner-deploy
2636

2737
jobs:
2838
lint:
@@ -41,11 +51,12 @@ jobs:
4151
when: always
4252
- notify_failing_main
4353

44-
test:
54+
unit-tests:
4555
executor: deploy
4656
steps:
4757
- checkout
4858
- run: ./do unit-tests
59+
- notify_failing_main
4960

5061
docs:
5162
executor: linux-vm
@@ -61,13 +72,12 @@ jobs:
6172
else
6273
echo "No uncommitted changes detected."
6374
fi
75+
- notify_failing_main
6476

6577
package-chart:
6678
executor: deploy
6779
steps:
6880
- checkout
69-
- attach_workspace:
70-
at: .
7181
- run:
7282
name: Install signing keys
7383
command: |
@@ -91,9 +101,42 @@ jobs:
91101
- run:
92102
name: List contents of Helm package
93103
command: tar -tvf "./target/circleci-server-monitoring-stack-$(./do version).tgz"
94-
- persist_to_workspace:
95-
root: .
96-
paths: [./target]
104+
- when:
105+
condition:
106+
equal: [<< pipeline.git.branch >>, main]
107+
steps:
108+
- persist_to_workspace:
109+
root: .
110+
paths: [./target]
111+
- notify_failing_main
112+
113+
deploy-chart:
114+
executor: deploy
115+
steps:
116+
- checkout
117+
- attach_workspace:
118+
at: .
119+
- run:
120+
name: Install package_cloud
121+
command: |
122+
sudo apt-get update && sudo apt-get install ruby-rubygems -y
123+
sudo gem install --no-document package_cloud
124+
- run:
125+
name: Publish Helm chart
126+
command: |
127+
package_cloud push circleci/server-monitoring-stack/helm/v1 \
128+
./target/circleci-server-monitoring-stack-"$(./do version)".tgz
129+
- run:
130+
name: "Push failed: Have you bumped the chart version?"
131+
command: |
132+
echo "Push failed; this may be because the chart version already exists. Consider the following options:"
133+
echo "1) Bump the version in Chart.yaml, run ./do helm-docs, and commit the changes."
134+
echo "2) Manually yank the version if you need to overwrite it."
135+
exit 1
136+
when: on_fail
137+
- notify_deploy:
138+
header: ":helm::server::grafana: Server monitoring Helm chart published"
139+
version: "$(./do version)"
97140
- notify_failing_main
98141

99142
smoke-tests:
@@ -180,3 +223,66 @@ commands:
180223
branch_pattern: main
181224
event: fail
182225
template: basic_fail_1
226+
227+
notify_deploy:
228+
parameters:
229+
header:
230+
type: string
231+
version:
232+
type: string
233+
steps:
234+
- run:
235+
name: Set environment for notification
236+
command: |
237+
echo "export HEADER_TEXT='<< parameters.header >>'" >> "$BASH_ENV"
238+
echo "export VERSION='<< parameters.version >>'" >> "$BASH_ENV"
239+
echo "export COMMIT_MSG='$(git show -s --format=%s HEAD | jq -R . | sed -e 's/^"//' -e 's/"$//')'" >> "$BASH_ENV"
240+
- slack/notify:
241+
event: pass
242+
channel: server-alerts
243+
custom: |
244+
{
245+
"blocks": [
246+
{
247+
"type": "header",
248+
"text": {
249+
"type": "plain_text",
250+
"text": "$HEADER_TEXT",
251+
"emoji": true
252+
}
253+
},
254+
{
255+
"type": "section",
256+
"fields": [
257+
{
258+
"type": "mrkdwn",
259+
"text": "*Project:*\n$CIRCLE_PROJECT_REPONAME"
260+
},
261+
{
262+
"type": "mrkdwn",
263+
"text": "*Author:*\n$CIRCLE_USERNAME"
264+
}
265+
]
266+
},
267+
{
268+
"type": "section",
269+
"fields": [
270+
{
271+
"type": "mrkdwn",
272+
"text": "*Version:*\n$VERSION"
273+
},
274+
{
275+
"type": "mrkdwn",
276+
"text": "*CircleCI Build:*\n<$CIRCLE_BUILD_URL|$CIRCLE_BUILD_NUM>"
277+
}
278+
]
279+
},
280+
{
281+
"type": "section",
282+
"text": {
283+
"type": "mrkdwn",
284+
"text": "*Commit Message:*\n$COMMIT_MSG"
285+
}
286+
}
287+
]
288+
}

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: circleci-server-monitoring-stack
33
description: A reference Helm chart for setting up a monitoring stack for CircleCI server
4-
version: 0.1.0
4+
version: 0.1.0-alpha.0
55
dependencies:
66
- name: prometheus-operator-crds
77
version: 18.0.*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This repository is currently under active development and is not yet a supported
99

1010
A reference Helm chart for setting up a monitoring stack for CircleCI server
1111

12-
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square)
12+
![Version: 0.1.0-alpha.0](https://img.shields.io/badge/Version-0.1.0--alpha.0-informational?style=flat-square)
1313

1414
## Installing the Monitoring Stack
1515

0 commit comments

Comments
 (0)