Skip to content

Commit

Permalink
feat: Add possibility to annotate grafana dashboards on helm deployme…
Browse files Browse the repository at this point in the history
…nt (#66)
  • Loading branch information
ppawlowski authored Jul 19, 2024
1 parent 5e1c020 commit 0c14a76
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .github/workflows/deploy_helm_chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Deploy helm chart to EKS cluster
on:
workflow_call:
inputs:
annotate_grafana:
description: 'Annotate Grafana'
type: boolean
required: false
default: false
chart_action:
description: 'Helm action to perform'
type: string
Expand Down Expand Up @@ -94,8 +99,14 @@ on:
chart_secret_values:
description: 'Comma separated list of value set for helms which should not be exposed in runner logs. Example: "key1=value1,key2=value2"'
required: false
grafana_domain:
description: 'Grafana domain'
required: false
grafana_token:
description: 'Grafana service account token'
required: false
op_token:
description: '1Password seervice account token'
description: '1Password service account token'
required: false
slack_token:
description: 'Slack token'
Expand Down Expand Up @@ -387,6 +398,23 @@ jobs:
retry-delay: 10s
retry-all: false

- name: Annotate Grafana
if: ${{ fromJson( inputs.annotate_grafana ) }}
env:
CHART: ${{ inputs.chart_name }}
GRAFANA_URL: ${{ secrets.grafana_domain }}
GRAFANA_TOKEN: ${{ secrets.grafana_token }}
ENVIRONMENT: ${{ inputs.environment }}
run: |
curl -X POST "${GRAFANA_URL}/api/annotations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${GRAFANA_TOKEN}" \
-d '{
"time": '$(date +%s%3N)',
"tags": ["deployment", "${{ env.CHART }}", "${{ env.ENVIRONMENT }}"],
"text": "Deploy of ${{ env.CHART }} to ${{ env.ENVIRONMENT }} from GitHub Actions: ${{ env.LAST_COMMIT_MSG }}"
}'
- name: Update notification
if: ${{ always() && fromJson( inputs.slack_notification_enabled ) }}
uses: slackapi/[email protected]
Expand Down

0 comments on commit 0c14a76

Please sign in to comment.