Created
February 18, 2021 21:56
-
-
Save marocchino/cf20bc557921021bcfc5d86a11587db8 to your computer and use it in GitHub Desktop.
validate dependabot yaml
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
#!/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