Update mods from known repos #3046
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 mods from known repos | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: "24 * * * *" | |
# 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-mods: | |
concurrency: | |
group: update-mods-${{ 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 from known repos. | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
cd source/scripts | |
npx tsx ./update-mods.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 | |
commit-message: Update mods | |
branch: update-mods | |
- 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 new files | |
if: (false) | |
run: | | |
git add $(git ls-files --others --exclude-standard mods) | |
( | |
git commit -m "Update mods" && | |
( | |
echo "MODS_UPDATED=yes" >> $GITHUB_ENV | |
) | |
) || true | |
- name: Push the updated files | |
if: (false) | |
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"}' |