Skip to content

Fetch JSON from API #12

Fetch JSON from API

Fetch JSON from API #12

Workflow file for this run

name: Fetch JSON from API
on:
schedule:
- cron: "0 0 * * *" # Runs every 24 hours
workflow_dispatch: # Allows manual triggering
jobs:
update-json:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch JSON
run: |
mkdir -p data
curl -sS https://smc-api.lodine.xyz/sites -o data/sites.json || echo "API is down, using last known copy"
- name: Check for changes
id: check_changes
run: |
git diff --quiet || echo "CHANGED=true" >> $GITHUB_ENV
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Create Pull Request
if: env.CHANGED == 'true'
uses: peter-evans/create-pull-request@v6
with:
branch: update-sites-json
delete-branch: true
title: "Update sites.json (Automated)"
body: "This PR updates the offline JSON copy from the API."
commit-message: "Update sites.json (Automated)"