-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2242 from dafyddj/ci/deploy-json
ci: deploy Renovate-style JSON to GitHub Pages
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Check if the jq binary exists | ||
if ! [ -x "$(command -v jq)" ]; then | ||
echo "Error: 'jq' binary not found or not executable" >&2 | ||
exit 1 | ||
fi | ||
|
||
readonly OUTPUT_DIR="${OUTPUT_DIR:-public}" | ||
|
||
process_repo() { | ||
# For each defined package, output a list of its versions to a file <package>.json in the output directory | ||
echo "$1" | jq -r '.local.repo | to_entries[] | "\(.key).json"' | while read -r filename; do | ||
echo "$1" | jq --arg pkg "${filename%.json}" \ | ||
'{"releases": [ .local.repo[$pkg] | keys[] | {version: .} ]}' > "$OUTPUT_DIR/$filename" | ||
done | ||
} | ||
|
||
repo_as_json=$(cat) | ||
|
||
if ! echo "$repo_as_json" | jq empty 2>/dev/null; then | ||
echo "Error: Valid JSON is required" >&2 | ||
exit 1 | ||
else | ||
if [ ! -d "$OUTPUT_DIR" ]; then | ||
mkdir -p "$OUTPUT_DIR" | ||
fi | ||
process_repo "$repo_as_json" | ||
fi |
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
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
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