Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions build-gp-config/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,37 @@ runs:
shell: bash --noprofile --norc -euo pipefail {0}
env:
CONFIG_FILE: ${{ inputs.config-file }}
GH_TOKEN: ${{ github.token }}
run: |
schema_url="$(jq -r '."$schema" // empty' "$CONFIG_FILE")"
if [ "$schema_url" == "" ]; then
schemafile="$(jq -r '."$schema" // empty' "$CONFIG_FILE")"
if [ "$schemafile" = "" ]; then
echo "::error::Config file $CONFIG_FILE is not using any schema."
exit 1
fi

# Download the schema via the REST API: unauthenticated fetches from
# raw.githubusercontent.com are rate-limited per runner IP (HTTP 429),
# and that host ignores auth tokens.
# See https://github.com/orgs/community/discussions/160828
case "$schemafile" in
https://raw.githubusercontent.com/*)
# https://raw.githubusercontent.com/OWNER/REPO/[refs/heads/|refs/tags/]REF/PATH -> repos/OWNER/REPO/contents/PATH?ref=REF
api_path="$(echo "$schemafile" | sed \
-e 's|^\(https://raw\.githubusercontent\.com/[^/]\{1,\}/[^/]\{1,\}\)/refs/heads/|\1/|' \
-e 's|^\(https://raw\.githubusercontent\.com/[^/]\{1,\}/[^/]\{1,\}\)/refs/tags/|\1/|' \
-e 's|^https://raw\.githubusercontent\.com/\([^/]\{1,\}\)/\([^/]\{1,\}\)/\([^/]\{1,\}\)/\(.\{1,\}\)$|repos/\1/\2/contents/\4?ref=\3|')"
if [ "$api_path" = "$schemafile" ]; then
echo "::error::Could not parse schema URL: $schemafile"
exit 1
fi
gh api -H "Accept: application/vnd.github.raw" "$api_path" > "$RUNNER_TEMP/schema.json"
schemafile="$RUNNER_TEMP/schema.json"
;;
esac

# renovate: datasource=pypi depName=check-jsonschema
CHECK_JSONSCHEMA_VERSION="0.37.0"
pip install --quiet "check-jsonschema==$CHECK_JSONSCHEMA_VERSION"
check-jsonschema --schemafile "$schema_url" "$CONFIG_FILE"
uvx "check-jsonschema@$CHECK_JSONSCHEMA_VERSION" --schemafile "$schemafile" "$CONFIG_FILE"

- name: Build config
id: build
Expand Down
Loading