Update mod repository data #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 scripts | |
npm install | |
cd ../website | |
npm install | |
- name: Update the repo data | |
run: | | |
cd 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: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/dispatches \ | |
-d '{"event_type":"trigger_deploy"}' |