This repository was archived by the owner on Oct 2, 2025. It is now read-only.
Update Player Script #2967
This file contains hidden or 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: Update Player Script | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 * * * *" # every hour | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| check-player: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main # Start from main branch | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2.0.2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --production | |
| - name: Run script and detect new player script | |
| id: run-script | |
| run: | | |
| set -eux | |
| # Create scripts directory if it doesn't exist | |
| mkdir -p scripts | |
| # Capture list of directories before | |
| BEFORE=$(find scripts -maxdepth 1 -type d -not -name "scripts" -exec basename {} \; | sort) | |
| # Run the TypeScript script | |
| bun run src/index.ts | |
| # Capture list of directories after | |
| AFTER=$(find scripts -maxdepth 1 -type d -not -name "scripts" -exec basename {} \; | sort) | |
| # Find the new directory | |
| NEW_DIR=$(comm -13 <(echo "$BEFORE") <(echo "$AFTER") | head -n 1) | |
| if [ -z "$NEW_DIR" ]; then | |
| echo "no_new_dir=true" >> "$GITHUB_OUTPUT" | |
| echo "No new directory created by script." | |
| exit 0 | |
| fi | |
| echo "Detected new player directory: $NEW_DIR" | |
| echo "new_dir=$NEW_DIR" >> "$GITHUB_OUTPUT" | |
| echo "no_new_dir=false" >> "$GITHUB_OUTPUT" | |
| - name: Commit to main if new directory exists | |
| if: steps.run-script.outputs.no_new_dir == 'false' | |
| run: | | |
| NEW_DIR="${{ steps.run-script.outputs.new_dir }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add "scripts/$NEW_DIR" | |
| git commit -m "chore: add new player script for $NEW_DIR" | |
| git push origin main |