Skip to content

Update mod repository data #40

Update mod repository data

Update mod repository data #40

# Simple workflow for deploying static content to GitHub Pages
name: Update mod repository data
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: "12 0 * * *"
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
jobs:
# Single deploy job since we're just deploying
update-github-data:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install npm modules
run: |
(cd source/scripts && npm install)
- name: Update the repo data
run: |
cd source/scripts
npx tsx ./update-github-icons.ts 2>&1
npx tsx ./update-repo-links.ts 2>&1
- name: Configure git user
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Commit the updated files
run: |
git add -A mods
(
git commit -m "Update mod data" &&
(
echo "MODS_UPDATED=yes" >> $GITHUB_ENV
)
) || true
- name: Push the updated files
if: (env.MODS_UPDATED == 'yes')
run: |
git pull --rebase
git push
- name: Trigger deploy
if: (env.MODS_UPDATED == 'yes')
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"trigger_deploy"}'