name: Crawl Versions from newreleases.io on: workflow_dispatch: permissions: contents: write pull-requests: write jobs: move-to-main-repo: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v2 with: repository: community-scripts/ProxmoxVED ref: main - name: Crawl from newreleases.io env: token: ${{ secrets.NEWRELEASES_TOKEN }} run: | page=1 projects_file="project_json" output_file="frontend/public/json/versions.json" echo "[]" > $output_file while true; do echo "Start loop on page: $page" projects=$(curl -s -H "X-Key: $token" "https://api.newreleases.io/v1/projects?page=$page") total_pages=$(echo "$projects" | jq -r '.total_pages') if [ -z "$total_pages" ] || [ "$total_pages" -eq 0 ]; then echo "No pages available. Exiting." exit 1 fi if [ $page == $total_pages ]; then break fi if [ -z "$projects" ] || ! echo "$projects" | jq -e '.projects' > /dev/null; then echo "No more projects or invalid response. Exiting." break fi echo "$projects" > "$projects_file" jq -r '.projects[] | "\(.id) \(.name)"' "$projects_file" | while read -r id name; do version=$(curl -s -H "X-Key: $token" "https://api.newreleases.io/v1/projects/$id/latest-release") version_data=$(echo "$version" | jq -r '.version // empty') if [ -n "$version_data" ]; then jq --arg name "$name" --arg version "$version_data" \ '. += [{"name": $name, "version": $version}]' "$output_file" > "$output_file.tmp" && mv "$output_file.tmp" "$output_file" fi done ((page++)) done - name: Commit JSON env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "GitHub Actions[bot]" git checkout -b update_versions || git checkout update_versions git add json/versions.json git commit -m "Update versions.json" git push origin update_versions --force gh pr create --title "[AUTOMATIC PR]Update versions.json" --body "Update versions.json, crawled from newreleases.io" --base main --head update_versions