Backup dashboards from grafana #2870
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backup dashboards from grafana | |
on: | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
- cron: '0 3/6 * * *' | |
workflow_dispatch: {} # manual build | |
# example query | |
# curl -H "Authorization: Bearer eyJrIjoidWUzaDNYQ01NVGxzcUNNOWYwaTE1YVZxcGxHbFduQUIiLCJuIjoiZGFzaGJvYXJkc19iYWNrdXAiLCJpZCI6MX0=" https://eu-metrics-monitoring.livepeer.live/grafana/api/dashboards/home | |
jobs: | |
backup: | |
name: Run backup script for ${{ matrix.grafana.env }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
grafana: | |
- env: prod | |
url: https://eu-metrics-monitoring.livepeer.live/grafana | |
secret: GRAFANA_PROD_READ_API_KEY | |
- env: staging | |
url: https://eu-metrics-monitoring.livepeer.monster/grafana | |
secret: GRAFANA_STAGING_READ_API_KEY | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- name: Run script to update dashboards | |
env: | |
API_KEY: ${{ secrets[matrix.grafana.secret] }} | |
run: | | |
./export.sh "${{ matrix.grafana.url }}" "${{ matrix.grafana.env }}" | |
- name: Commit and push changes | |
id: branch-commit | |
uses: devops-infra/[email protected] | |
with: | |
github_token: ${{ secrets.PUSH_TOKEN }} | |
target_branch: backup/grafana-${{ matrix.grafana.env }} | |
commit_prefix: "[AUTO-COMMIT] " | |
commit_message: 'Backup grafana dashboards' | |
force: true | |
- name: Create pull request with new dashboards | |
uses: devops-infra/[email protected] | |
with: | |
github_token: ${{ secrets.PUSH_TOKEN }} | |
source_branch: ${{ steps.branch-commit.outputs.branch_name }} | |
target_branch: master | |
title: '[AUTO] Dashboards backup (${{ matrix.grafana.env }})' | |
label: grafana | |
get_diff: true | |
allow_no_diff: false |