Update data from ComputerElite #137
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 data from ComputerElite | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: "36 0 * * *" | |
# Sets permissions of the GITHUB_TOKEN to allow push and requesting PRs | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
# Single deploy job since we're just deploying | |
update-computer-json: | |
concurrency: | |
group: update-computer-json-${{ github.ref }} | |
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 mods.json from ComputerElite | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
wget "https://computerelite.github.io/tools/Beat_Saber/mods.json" -O source/website/public/mods.json | |
cd source/scripts | |
npx tsx ./split.ts 2>&1 | |
npx tsx ./delete-missing-mods.ts 2>&1 | |
npx tsx ./update-github-icons.ts 2>&1 | |
npx tsx ./update-covers.ts 2>&1 | |
- name: Only keep new files. | |
run: | | |
git add $(git ls-files --others --exclude-standard mods) | |
git checkout . | |
git reset | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
title: Update Mods from ComputerElite | |
commit-message: Update mods | |
branch: update-mods-computer | |
- name: Configure git user | |
if: (false) | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Commit the updated files | |
if: (false) | |
run: | | |
git add -A mods | |
( | |
git commit -m "Update mods" && | |
( | |
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"}' |