Auto-Update #425
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
name: Auto-Update | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 */3 * *" | |
jobs: | |
update: | |
name: Update | |
outputs: | |
publish: ${{ steps.commit.outputs.publish }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "yarn" | |
- name: Update data | |
run: | | |
yarn install --immutable --immutable-cache --check-cache | |
yarn update | |
- name: Commit changes | |
id: commit | |
run: | | |
if [[ `git status --porcelain` ]]; then | |
echo "Committing changes." | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "Stations Auto-Update (`date '+%Y.%m.%d %H:%M:%S'`)" -a || true | |
git push | |
echo "publish=true" >> $GITHUB_OUTPUT | |
else | |
echo "No changes." | |
echo "publish=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Discord message | |
uses: sarisia/actions-status-discord@v1 | |
if: always() | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
description: ${{ steps.commit.outputs.publish == 'true' && 'Publish started' || 'Publish skipped' }} | |
color: ${{ steps.commit.outputs.publish == 'true' && '0x009800' || '0x1e1f22' }} | |
publish: | |
name: Publish | |
needs: update | |
if: needs.update.outputs.publish == 'true' || github.event_name == 'workflow_dispatch' | |
uses: ./.github/workflows/publish.yml |