Skip to content

Commit

Permalink
Improve get_params error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jan 8, 2025
1 parent b011070 commit d3e3b39
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/multi_auto_snapshot_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ jobs:
run: |
MC_VERSION="${{ inputs.mc_version }}"
if [ -z "$MC_VERSION" ]; then
MC_VERSION=$(curl -s https://launchermeta.mojang.com/mc/game/version_manifest.json \
| jq -r '.latest.snapshot')
RESPONSE=$(curl -s https://launchermeta.mojang.com/mc/game/version_manifest.json)
MC_VERSION=$(echo "$RESPONSE" | jq -r '.latest.snapshot')
if [ -z "$MC_VERSION" ]; then
echo "No latest Minecraft snapshot found"
echo "Response: $RESPONSE"
exit 1
fi
fi
echo "mc_version=$MC_VERSION" >> $GITHUB_OUTPUT
echo "Minecraft version: \`$MC_VERSION\`" >> $GITHUB_STEP_SUMMARY
Expand All @@ -63,24 +68,26 @@ jobs:
echo "Loader version: \`$LOADER_VERSION\`" >> $GITHUB_STEP_SUMMARY
else
echo "No yarn/loader versions found for ${{ steps.get_mc_version.outputs.mc_version }}"
echo "Response: $RESPONSE"
exit 1
fi
- name: Get Fabric API version
id: get_fapi_version
run: |
FAPI_VERSION="${{ inputs.fapi_version }}"
if [ -z "$FAPI_VERSION" ]; then
MC_VERSION="${{ steps.get_mc_version.outputs.mc_version }}"
RESPONSE=$(curl -s \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/FabricMC/fabric/releases?per_page=100")
MC_VERSION="${{ steps.get_mc_version.outputs.mc_version }}"
FAPI_VERSION=$(echo "$RESPONSE" \
| jq -r --arg MC_VERSION "$MC_VERSION" \
'.[] | select(.name | contains($MC_VERSION)) | .tag_name' \
| head -n 1)
if [ -z "$FAPI_VERSION" ]; then
echo "No Fabric API version found for $MC_VERSION"
echo "Response: $RESPONSE"
exit 1
fi
fi
Expand All @@ -91,11 +98,17 @@ jobs:
run: |
CF_GAME_VERSION="${{ inputs.cf_game_version }}"
if [ -z "$CF_GAME_VERSION" ]; then
CF_GAME_VERSION=$(curl -s \
RESPONSE=$(curl -s \
-H "Accept: application/json" \
-H "x-api-key: ${{ secrets.CURSEFORGE_API_KEY }}" \
"https://api.curseforge.com/v1/games/minecraft/mods/306612/files?pageSize=1" \
"https://api.curseforge.com/v1/games/minecraft/mods/306612/files?pageSize=1")
CF_GAME_VERSION=$(echo "$RESPONSE" \
| jq -r '.data[0].gameVersions[] | select(. != "Fabric")')
if [ -z "$CF_GAME_VERSION" ]; then
echo "No CurseForge game version found for ${{ steps.get_mc_version.outputs.mc_version }}"
echo "Response: $RESPONSE"
exit 1
fi
fi
echo "cf_game_version=$CF_GAME_VERSION" >> $GITHUB_OUTPUT
echo "CurseForge game version: \`$CF_GAME_VERSION\`" >> $GITHUB_STEP_SUMMARY
Expand Down

0 comments on commit d3e3b39

Please sign in to comment.