Publish WildRift Stats to Github Pages #172
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: Publish WildRift Stats to Github Pages | |
| on: | |
| push: | |
| branches: | |
| - master | |
| schedule: | |
| # Run every night at 02:00 UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| env: | |
| CI: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish-data: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e #v4 | |
| with: | |
| node-version: '24' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d #v4 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build TypeScript | |
| run: pnpm compile | |
| - name: Run script | |
| run: | | |
| for i in 1 2 3; do | |
| node dist/main.js && break || echo "Attempt $i failed, retrying..." | |
| done | |
| - name: Deploy to GitHub Pages | |
| run: | | |
| git config user.name "$GITHUB_ACTOR" | |
| git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
| git remote add gh-pages-remote https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git \ | |
| || git remote set-url gh-pages-remote https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git | |
| git fetch --no-recurse-submodules | |
| git worktree add ./gh-pages gh-pages || true | |
| cd gh-pages | |
| git rm -r . | |
| cp -r ../public/. . | |
| git add . | |
| if git diff --cached --quiet; then | |
| echo "No changes detected. Skipping push." | |
| exit 0 | |
| fi | |
| git commit --message="Deploying to GitHub Pages from $GITHUB_SHA" | |
| git push gh-pages-remote gh-pages:gh-pages | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} |