Skip to content

Deploy Annotation to Grafana (Manual Trigger) #27

Deploy Annotation to Grafana (Manual Trigger)

Deploy Annotation to Grafana (Manual Trigger) #27

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}
}"
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: actions/send-ci-cd-trace/package-lock.json
- name: Install Dependencies
run: npm ci --ignore-scripts
working-directory: actions/send-ci-cd-trace
- name: Build the Action
run: npm run build
working-directory: actions/send-ci-cd-trace
- name: Send Trace to Azure Monitor
uses: ./actions/send-ci-cd-trace
with:
connection_string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }}
app: "${{ github.event.inputs.app }}"
team: "${{ github.event.inputs.team }}"