diff --git a/.github/workflows/lint-dashboards.yaml b/.github/workflows/lint-dashboards.yaml new file mode 100644 index 00000000..3802dc8b --- /dev/null +++ b/.github/workflows/lint-dashboards.yaml @@ -0,0 +1,34 @@ +name: Lint dashboards + +on: + push: + branches: + - main + paths: + - 'charts/fission-all/dashboards/**.json' + pull_request: + branches: + - main + paths: + - 'charts/fission-all/dashboards/**.json' + workflow_dispatch: + +jobs: + lint-dashboards: + runs-on: ubuntu-latest + + steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.5 + + - name: Check out code + uses: actions/checkout@v3 + + - name: Install dashboard linter + run: | + go install github.com/grafana/dashboard-linter + + - name: Run dashboard linter + run: ./hack/lint-dashboards.sh diff --git a/hack/lint-dashboards.sh b/hack/lint-dashboards.sh new file mode 100755 index 00000000..e1524c8d --- /dev/null +++ b/hack/lint-dashboards.sh @@ -0,0 +1,16 @@ +if ! command -v dashboard-linter >/dev/null 2>&1; then + echo "dashboard-linter is not installed" + exit 1; +fi +BASE_PATH=$(pwd) + +if [[ -z "$BASE_PATH" ]] ; then + BASE_PATH=$(GITHUB_WORKSPACE) +fi + +DASHBOARD_PATH="$BASE_PATH/charts/fission-all/dashboards/*" + +for f in $DASHBOARD_PATH +do + dashboard-linter lint --strict $f +done \ No newline at end of file