forked from openshift-helm-charts/development
-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (89 loc) · 4.37 KB
/
metrics.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Scheduled Metrics
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
# Production metrics require secret SEGMENT_WRITE_KEY
# Test metrics require secret SEGMENT_TEST_WRITE_KEY
production-data:
description: "Upload metrics to production data {true,false}"
required: true
default: "false"
jobs:
metrics:
name: Collect and Send Metrics
runs-on: ubuntu-20.04
env:
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
SEGMENT_TEST_WRITE_KEY: ${{ secrets.SEGMENT_TEST_WRITE_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.x Part 1
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Set up Python 3.x Part 2
run: |
# set up python
python3 -m venv ve1
cd scripts && ../ve1/bin/pip3 install -r requirements.txt && cd ..
cd scripts && ../ve1/bin/python3 setup.py install && cd ..
- name: Release Metrics
id: release_metrics
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
if [[ "${{github.event.inputs.production-data}}" == "true" ]]; then
echo "Workflow dispatch using production write key"
WRITE_KEY=${SEGMENT_WRITE_KEY}
ID_PREFIX="helm-metric-downloads"
else
echo "Workflow dispatch using test write key"
WRITE_KEY=${SEGMENT_TEST_WRITE_KEY}
ID_PREFIX="helm-test-metric-downloads"
fi
elif [[ "${{github.repository}}" == "openshift-helm-charts/development" ]]; then
echo "Scheduled dispatch using production write key"
WRITE_KEY=${SEGMENT_WRITE_KEY}
ID_PREFIX="helm-metric-downloads"
if [ "${SEGMENT_WRITE_KEY}" != "" ]; then
WRITE_KEY=${SEGMENT_WRITE_KEY}
else
echo "Error: Scheduled dispatch is missing write key"
exit 1
fi
else
echo "Scheduled dispatch not on valid repo, do not set write key"
WRITE_KEY=""
fi
if [ "${WRITE_KEY}" != "" ]; then
ve1/bin/metrics --write-key=${WRITE_KEY} --metric-type=nightly --prefix="${ID_PREFIX}"
else
echo "Do not collect metrics, required segment write key is not set"
fi
- name: Send message to helm_dev slack channel
id: notify_dev
if: ${{ always() && github.event_name == 'schedule' && github.repository == 'openshift-helm-charts/development' && steps.release_metrics.conclusion != 'success' }}
uses: archive/github-actions-slack@v2.7.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: C02979BDUPL
slack-text: Failure! Nightly collection of metrics. See '${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}'
- name: Result from "Send Message to helm_dev slack channel"
if: ${{ always() && github.event_name == 'schedule' && github.repository == 'openshift-helm-charts/development' && steps.release_metrics.conclusion != 'success' }}
run: echo "The result was ${{ steps.notify_dev.outputs.slack-result }}"
- name: Send message to helm_notify slack channel
id: notify
if: ${{ always() && github.event_name == 'schedule' && github.repository == 'openshift-helm-charts/development' && steps.release_metrics.conclusion == 'success' }}
uses: archive/github-actions-slack@v2.7.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: C04K1ARMH8A
slack-text: Success! Nightly collection of metrics. See '${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}'
- name: Result from "Send Message to helm_notify slack channel"
if: ${{ always() && github.event_name == 'schedule' && github.repository == 'openshift-helm-charts/development' && steps.release_metrics.conclusion == 'success' }}
run: echo "The result was ${{ steps.notify.outputs.slack-result }}"