Skip to content

Commit

Permalink
switch to hook-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
akerl committed Jun 21, 2023
1 parent 67c19ee commit 7c3173d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
16 changes: 16 additions & 0 deletions .github/exporter.sh
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

URL="https://exporter.akerl.app/metric"
AUTH="Authorization: Bearer $EXPORTER_TOKEN"
if [[ "$JOB_STATUS" == "success" ]] ; then
VALUE=1
else
VALUE=0
fi
BODY="{\"name\":\"gh/${GITHUB_REPOSITORY}\",\"metrics\":[{\"name\":\"ghactions\",\"type\":\"gauge\",\"tags\":{\"repo\":\"${GITHUB_REPOSITORY}\"},\"value\":\"${VALUE}\"}]}"

echo "$BODY"

curl -i -XPOST -d "$BODY" -H"$AUTH" "$URL"
24 changes: 5 additions & 19 deletions .github/workflows/build.yml
Expand Up @@ -29,23 +29,9 @@ jobs:
bundle exec rake release
env:
BLACKSMITH_FORGE_API_KEY: ${{ secrets.BLACKSMITH_FORGE_API_KEY }}
- name: Post to a Slack channel
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.23.0
- name: Post to hook-exporter
run: ./.github/exporter.sh
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"text": "*${{ github.repository }}*\nBuild failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*${{ github.repository }}*\nBuild failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
EXPORTER_TOKEN: ${{ secrets.EXPORTER_TOKEN }}
JOB_STATUS: ${{ job.status }}
if: ${{ always() }}

0 comments on commit 7c3173d

Please sign in to comment.