Skip to content

Commit

Permalink
added checks via git diff to ensure only changed files exec POST req
Browse files Browse the repository at this point in the history
  • Loading branch information
ehearneRedHat committed May 16, 2024
1 parent cd20313 commit 87ec520
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/upload-dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,31 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v2
- name: Set changed files variable
id: changes
run: |
echo "changed_files=$(git diff --name-only HEAD^ HEAD)" >> $GITHUB_ENV
- name: Upload Dashboard
run: |
# Push new dashboard changes
# Init variable with base64 auth
auth=$(echo -n ${{ secrets.GRAFANA_USERNAME }}:${{ secrets.GRAFANA_PASSWORD }} | base64)
# App Developer Dashboard
curl -X POST -F "json=@./examples/dashboards/app_developer.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20970/revisions"
# Check and upload each dashboard if it has changed
if [[ "$changed_files" == *"examples/dashboards/app_developer.json"* ]]; then
echo "Uploading App Developer Dashboard"
curl -X POST -F "json=@./examples/dashboards/app_developer.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20970/revisions"
fi
# Business User Dashboard
curl -X POST -F "json=@./examples/dashboards/business_user.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20981/revisions"
if [[ "$changed_files" == *"examples/dashboards/business_user.json"* ]]; then
echo "Uploading Business User Dashboard"
curl -X POST -F "json=@./examples/dashboards/business_user.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20981/revisions"
fi
# Platform Engineer Dashboard
curl -X POST -F "json=@./examples/dashboards/platform_engineer.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20982/revisions"
if [[ "$changed_files" == *"examples/dashboards/platform_engineer.json"* ]]; then
echo "Uploading Platform Engineer Dashboard"
curl -X POST -F "json=@./examples/dashboards/platform_engineer.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20982/revisions"
fi
env:
changed_files: ${{ env.changed_files }}

0 comments on commit 87ec520

Please sign in to comment.