name: "Grafana: Publish dashboards"

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - grafana/**
      - .github/workflows/grafana-publish.yml

permissions:
  contents: read

concurrency:
  group: grafana-publish
  cancel-in-progress: false

jobs:
  publish:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1

      - name: Install mise
        uses: jdx/mise-action@c37c93293d6b742fc901e1406b8f764f6fb19dac # v2.4.4
        with:
          version: 2026.5.11
          install: true

      - name: Publish dashboards
        run: |
          cd grafana
          # https://pytorchci.grafana.net/dashboards/f/fvnzj9
          mise run push --folder fvnzj9
        env:
          GRAFANA_TOKEN: ${{ secrets.PYTORCHCI_GRAFANA_API_TOKEN }}
