Skip to content

Instantly share code, notes, and snippets.

@marocchino
Created February 18, 2021 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marocchino/cf20bc557921021bcfc5d86a11587db8 to your computer and use it in GitHub Desktop.
Save marocchino/cf20bc557921021bcfc5d86a11587db8 to your computer and use it in GitHub Desktop.
validate dependabot yaml
#!/bin/bash
set -e
YAML=$(cat "${1:-.github/dependabot.yml}")
YAML="${YAML//$'\n'/\\n}"
YAML="${YAML//\"/\\\"}"
JSON="{\"config-file-body\": \"$YAML\"}"
curl -X "POST" "https://api.dependabot.com/config_files/validate" \
-H 'Host: api.dependabot.com' \
-H 'Referer: https://dependabot.com/docs/config-file/validator/' \
-H 'Content-Type: application/json' \
-H 'Origin: https://dependabot.com' \
-H 'Connection: keep-alive' \
-d "$JSON" -s | jq --raw-output $'
if (.errors | length) != 0
then "🚫 validation failed\n| title | detail | source |\n| -- | -- | -- |\n" + (.errors | map(@text "| \(.title) | \(.detail) | \(.source.pointer) |") | join("\n"))
else "✅no validation errors"
end'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment