feat: Accelerate the Doom — gamified clicker mechanic with upgrades, challenges, and milestone racing #29
Workflow file for this run
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: PR Preview | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| preview: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Regenerate milestones-data.js from YAML | |
| run: npm run build:milestones | |
| - name: Deploy PR preview to gh-pages branch | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: . | |
| destination_dir: previews/pr-${{ github.event.number }} | |
| # Preserve existing previews and production files | |
| keep_files: true | |
| # Exclude non-site files | |
| exclude_assets: '.github,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml' | |
| - name: Post or update preview URL comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const sha = context.payload.pull_request.head.sha.slice(0, 7); | |
| const url = `https://nitrocode.github.io/token-deathclock/previews/pr-${prNumber}/`; | |
| const body = [ | |
| '## 👁️ PR Preview', | |
| '', | |
| `🚀 **[Open Preview](${url})**`, | |
| '', | |
| `> Deployed from commit \`${sha}\` · Updates on every push to this PR`, | |
| '> _(Preview is removed automatically when the PR is closed.)_', | |
| ].join('\n'); | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| }); | |
| const existing = comments.find(c => | |
| c.user.type === 'Bot' && c.body.includes('## 👁️ PR Preview') | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body, | |
| }); | |
| } |