Skip to content

Fetch Discord Events (Node.js) #121

Fetch Discord Events (Node.js)

Fetch Discord Events (Node.js) #121

name: Fetch Discord Events (Node.js)
on:
schedule:
# Run once a day at 20:00
- cron: '0 20 * * *'
workflow_dispatch: # Allows for a manual run
jobs:
fetch_and_dump:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Step 1: Check out the repository code
- name: Checkout repository
uses: actions/checkout@v5
# Step 2: Set up a Node.js environment
- uses: pnpm/action-setup@v4
with:
run_install: true
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: '22.x' # Or any version you prefer
cache: pnpm
# Step 3: Install Node.js dependencies
- name: Install dependencies
run: pnpm install
working-directory: 'automation'
# Step 4: Run the Node.js script to fetch events and save to a file
- name: Fetch and save events
run: node get_events.js
working-directory: 'automation'
env:
# Use the GitHub Secret we created to pass the token
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
# Step 5: Commit the new JSON file back to the repository
- name: Commit and push changes
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add scheduled_events.json
git commit -m "chore(scheduled-events): Update scheduled events from Discord API" || echo "No changes to commit"
git push origin HEAD:event-data --force