diff --git a/.github/workflows/validate-manifest.yml b/.github/workflows/validate-manifest.yml new file mode 100644 index 00000000..f02dee62 --- /dev/null +++ b/.github/workflows/validate-manifest.yml @@ -0,0 +1,37 @@ +name: Validate manifest.json + +on: push + +jobs: + validate: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Validate manifest.json + id: validate_manifest + run: | + echo "Validating manifest files" + for item in $(jq -c -r '.lists.[].file | select( . != null )' manifest.json); do + if test -f $item; then + echo "$item file is listed in the manifest, and exists in the repository" + else + echo "::error file=manifest.json,title=Invalid-Manifest::$item file is listed in the manifest, but the file does not exist" + exit 1 + fi + done + + echo "Validating manifest urls" + for item in $(jq -c -r '.lists.[].url | select( . != null )' manifest.json); do + urlstatus=$(curl -H 'Cache-Control: no-cache' -o /dev/null --silent --head --write-out "$URL %{http_code}" "$item") + if [ $urlstatus -ne 200 ]; then + echo "::error file=manifest.json,title=Invalid-Manifest::$item URL is listed in the manifest, but the received HTTP status of $urlstatus" + exit 1 + fi + done + + echo "Validation complete"