Skip to content

Fetch and Update Datasets #117

Fetch and Update Datasets

Fetch and Update Datasets #117

name: Fetch and Update Datasets
on:
schedule:
- cron: "0 */12 * * *" # Runs every 12 hours
workflow_dispatch: # Allows manual triggering
permissions:
contents: write
jobs:
fetch-data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: latest
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.12.3
run_install: false
- name: Install Dependencies
run: pnpm install
- name: Fetch Datasets
run: |
mkdir -p src/datasets # Create the datasets directory if it doesn't exist
set -e # Exit immediately if a command exits with a non-zero status
echo "Fetching versions..."
curl -fs "https://ddragon.leagueoflegends.com/api/versions.json" | jq '.' > src/datasets/versions.json
patchVer=$(jq -r '.[0]' src/datasets/versions.json) # Extract the latest version
if [ -z "$patchVer" ]; then
echo "Failed to fetch DataDragon version."
exit 1
fi
echo "Fetching champion dataset..."
curl -fs "https://ddragon.leagueoflegends.com/cdn/${patchVer}/data/en_US/champion.json" | jq '.' > src/datasets/champion.json
echo "Fetching runes dataset..."
curl -fs "https://ddragon.leagueoflegends.com/cdn/${patchVer}/data/en_US/runesReforged.json" | jq '.' > src/datasets/runesReforged.json
echo "Fetching summoner spells dataset..."
curl -fs "https://ddragon.leagueoflegends.com/cdn/${patchVer}/data/en_US/summoner.json" | jq '.' > src/datasets/summoner.json
echo "Fetching items dataset..."
curl -fs "https://ddragon.leagueoflegends.com/cdn/${patchVer}/data/en_US/item.json" | jq '.' > src/datasets/item.json
echo "Fetching queues dataset..."
curl -fs "https://static.developer.riotgames.com/docs/lol/queues.json" | jq '.' > src/datasets/queues.json
echo "Fetching arena dataset..."
curl -fs "https://raw.communitydragon.org/latest/cdragon/arena/en_us.json" | jq '.' > src/datasets/arena.json
- name: Commit and Push Changes
run: |
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
git add src/datasets/*.json # Add all JSON files
git commit -m "Update datasets" || echo "No changes to commit"
git push