Skip to content

Deploy Annotation to Grafana (Manual Trigger) #31

Deploy Annotation to Grafana (Manual Trigger)

Deploy Annotation to Grafana (Manual Trigger) #31

name: Deploy Annotation to Grafana (Manual Trigger)
on:
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'grafana'
version:
description: 'Application version'
required: true
team:
description: 'Owner or team name'
required: true
default: 'platform'
app:
description: 'App name'
required: true
default: 'platform'
permissions:
id-token: write
contents: write
jobs:
deploy-annotation:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: 'Azure login'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Create Grafana Annotation
run: |
timestamp=$(date +%s%3N) # Use millisecond resolution, as requested by the annotations api
curl -X POST "${{ secrets.GRAFANA_URL }}/api/annotations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.GRAFANA_SA_TOKEN }}" \
-d "{
\"text\": \"Deployed ${{ github.event.repository.name }} version ${{ github.event.inputs.version }}\",
\"tags\": [
\"deployment\",
\"env:${{ github.event.inputs.environment }}\",
\"app:${{ github.event.inputs.app }}\",
\"team:${{ github.event.inputs.owner }}\"
],
\"time\": ${timestamp}
}"
- name: Send Trace to Azure Monitor
uses: altinn/altinn-platform/actions/send-ci-cd-trace@v1.0.0
with:
connection_string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }}
app: "${{ github.event.inputs.app }}"
team: "${{ github.event.inputs.team }}"
repo_token: ${{ secrets.GITHUB_TOKEN }}