Skip to content

Merge pull request #200 from anka-afk/main #308

Merge pull request #200 from anka-afk/main

Merge pull request #200 from anka-afk/main #308

Workflow file for this run

name: Validate plugin.json
on:
push:
paths:
- "plugins.json"
pull_request:
paths:
- "plugins.json"
workflow_dispatch: # 支持手动触发
jobs:
validate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0 # 获取完整历史记录以便比较文件
- name: Validate plugins.json format
run: |
sudo apt-get install jq
jq . plugins.json > /dev/null
- name: Check repository URLs
run: |
# 提取 plugins.json 中的 repo 字段并检查可访问性
repos=$(jq -r '.. | objects | .repo? // empty' plugins.json)
unreachable_urls=() # 初始化一个数组用于记录不可访问的 URL
for repo in $repos; do
sleep 1
if curl --output /dev/null --silent --head --fail --retry 3 "$repo"; then
echo "Repository $repo is accessible."
else
echo "Repository $repo is NOT accessible."
unreachable_urls+=("$repo") # 将不可访问的 URL 添加到数组
fi
done
# 检查是否有不可访问的 URL
if [ ${#unreachable_urls[@]} -ne 0 ]; then
echo "The following repositories are NOT accessible:"
for url in "${unreachable_urls[@]}"; do
echo "$url" # 输出每个不可访问的 URL
done
exit 1 # 结束运行并标记失败状态
else
echo "All repositories are accessible."
fi