Skip to content

Commit

Permalink
JSON validation GitHub workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Jurj-Bogdan <[email protected]>
  • Loading branch information
Jurj-Bogdan committed Dec 10, 2024
1 parent 4719966 commit 0325362
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/validate-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Validate ecosystem packages JSON file

on:
pull_request:
push:
branches:
tags:

jobs:
validate-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
packages=$(cat ./data/ecosystem/ecosystem-packages.json);
if [ ! -z "$packages" ] && [ $(echo $packages | jq empty > /dev/null 2>&1; echo $?) -eq 0 ]; then
for key in packagistUrl keywords homepage category usage; do
if ! $(echo $packages | jq ".[]" | jq "has(\"$key\")" | jq 'select(. == false)'); then
echo "Invalid JSON. Missing key \"$key\"."
exit 1;
fi
done
echo "Valid JSON."
exit 0;
else
echo "Invalid JSON."
exit 1;
fi
5 changes: 0 additions & 5 deletions data/ecosystem/ecosystem-packages.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
[
{
"packagistUrl": "https://packagist.org/packages/akrabat/ip-address-middleware",
"githubUrl": "https://github.com/akrabat/ip-address-middleware",
"keywords": ["ip", "address", "middleware"],
"homepage": "",
"category": "tool",
"usage": "mezzio"
},
{
"packagistUrl": "https://packagist.org/packages/netglue/laminas-messenger",
"githubUrl": "https://github.com/netglue/laminas-messenger",
"keywords": ["laminas", "messenger"],
"homepage": "",
"category": "tool",
"usage": "mezzio"
},
{
"packagistUrl": "https://packagist.org/packages/dotkernel/dot-errorhandler",
"githubUrl": "https://github.com/dotkernel/dot-errorhandler",
"keywords": ["error-handling"],
"homepage": "https://dotkernel.com",
"category": "integration",
"usage": "mezzio"
},
{
"packagistUrl": "https://packagist.org/packages/roave/psr-container-doctrine",
"githubUrl": "",
"keywords": ["middleware", "doctrine"],
"homepage": "",
"category": "integration",
"usage": "mezzio"
},
{
"packagistUrl": "https://packagist.org/packages/asgrim/mini-mezzio",
"githubUrl": "https://github.com/asgrim/mini-mezzio",
"keywords": ["mezzio"],
"homepage": "",
"category": "skeleton",
Expand Down

0 comments on commit 0325362

Please sign in to comment.