Skip to content

Commit

Permalink
Update fetch-sites action
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitrrine committed Mar 8, 2025
1 parent 36c44f8 commit 27833b9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/fetch-sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@ name: Fetch JSON from API

on:
schedule:
- cron: "0 * * * *" # Runs every 24 hours (adjust UTC if needed)
- cron: "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: Commit and push if changed
if: env.CHANGED == 'true'
- 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"
git add data/sites.json
git commit -m "Update sites.json (Automated)"
git push
- 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)"

0 comments on commit 27833b9

Please sign in to comment.