Skip to content

Commit 5e1fc81

Browse files
committed
switch to hook-exporter
1 parent adab73f commit 5e1fc81

2 files changed

Lines changed: 21 additions & 20 deletions

File tree

.github/exporter.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
URL="https://exporter.akerl.app/metric"
6+
AUTH="Authorization: Bearer $EXPORTER_TOKEN"
7+
if [[ "$JOB_STATUS" == "success" ]] ; then
8+
VALUE=1
9+
else
10+
VALUE=0
11+
fi
12+
BODY="{\"name\":\"gh/${GITHUB_REPOSITORY}\",\"metrics\":[{\"name\":\"ghactions\",\"type\":\"gauge\",\"tags\":{\"repo\":\"${GITHUB_REPOSITORY}\"},\"value\":\"${VALUE}\"}]}"
13+
14+
echo "$BODY"
15+
16+
curl -i -XPOST -d "$BODY" -H"$AUTH" "$URL"

.github/workflows/build.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,9 @@ jobs:
3333
run: make release
3434
env:
3535
GITHUB_TOKEN: ${{ github.token }}
36-
- name: Post to a Slack channel
37-
if: ${{ failure() }}
38-
uses: slackapi/slack-github-action@v1.23.0
36+
- name: Post to hook-exporter
37+
run: ./.github/exporter.sh
3938
env:
40-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
41-
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
42-
with:
43-
payload: |
44-
{
45-
"text": "*${{ github.repository }}*\nBuild failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
46-
"blocks": [
47-
{
48-
"type": "section",
49-
"text": {
50-
"type": "mrkdwn",
51-
"text": "*${{ github.repository }}*\nBuild failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
52-
}
53-
}
54-
]
55-
}
56-
39+
EXPORTER_TOKEN: ${{ secrets.EXPORTER_TOKEN }}
40+
JOB_STATUS: ${{ job.status }}
41+
if: ${{ always() }}

0 commit comments

Comments
 (0)