From e53c3e34ed052c3666cf0705c6aaf9d01643af19 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 18:45:14 +0000 Subject: [PATCH 1/4] feat: show mobile and desktop screenshots in PR preview comment Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/af3efb09-f782-4150-882c-d9ec820c6128 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- .github/workflows/preview.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 1596bfb..70d0c32 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -27,6 +27,12 @@ jobs: - name: Build all generated files run: npm run build + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium + + - name: Capture desktop and mobile screenshots + run: npm run screenshots + - name: Deploy PR preview to gh-pages branch uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 with: @@ -45,6 +51,7 @@ jobs: 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 ssBase = `${url}screenshots`; const body = [ '## ๐Ÿ‘๏ธ PR Preview', '', @@ -52,6 +59,12 @@ jobs: '', `> Deployed from commit \`${sha}\` ยท Updates on every push to this PR`, '> _(Preview is removed automatically when the PR is closed.)_', + '', + '### Screenshots', + '', + '| Desktop | Mobile |', + '|:-------:|:------:|', + `| ![Desktop](${ssBase}/desktop.png) | ![Mobile](${ssBase}/mobile.png) |`, ].join('\n'); const { data: comments } = await github.rest.issues.listComments({ From 7b68663c337dda0847e095a2d8913f0161e45db3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 19:00:32 +0000 Subject: [PATCH 2/4] fix: fix preview CSS/JS loading and screenshots in PR comments Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/4978ac3b-8917-4f33-a7e0-e2714ee2f609 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- .github/workflows/preview.yml | 52 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 70d0c32..6d40deb 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -33,6 +33,46 @@ jobs: - name: Capture desktop and mobile screenshots run: npm run screenshots + - name: Upload screenshots to GitHub + id: upload-screenshots + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const fs = require('fs'); + const prNumber = context.payload.pull_request.number; + const branch = 'gh-pages'; + const owner = context.repo.owner; + const repo = context.repo.repo; + + for (const name of ['desktop', 'mobile']) { + const localPath = `screenshots/${name}.png`; + const ghPath = `previews/pr-${prNumber}/screenshots/${name}.png`; + const content = fs.readFileSync(localPath, { encoding: 'base64' }); + + let sha; + try { + const { data } = await github.rest.repos.getContent({ + owner, repo, path: ghPath, ref: branch, + }); + sha = data.sha; + } catch (_) { /* file doesn't exist yet */ } + + await github.rest.repos.createOrUpdateFileContents({ + owner, repo, + path: ghPath, + message: `chore: update ${name} screenshot for PR #${prNumber}`, + content, + branch, + ...(sha ? { sha } : {}), + }); + + core.setOutput(`${name}_url`, + `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${ghPath}`); + } + + - name: Remove .gitignore so built files are included in deploy + run: rm .gitignore + - name: Deploy PR preview to gh-pages branch uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 with: @@ -41,17 +81,21 @@ jobs: 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' + # Exclude non-site files (keep in sync with deploy.yml; screenshots handled via Content API) + exclude_assets: '.github,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml,project-stats.yaml,screenshots' - name: Post or update preview URL comment uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + DESKTOP_URL: ${{ steps.upload-screenshots.outputs.desktop_url }} + MOBILE_URL: ${{ steps.upload-screenshots.outputs.mobile_url }} 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 ssBase = `${url}screenshots`; + const desktopUrl = process.env.DESKTOP_URL; + const mobileUrl = process.env.MOBILE_URL; const body = [ '## ๐Ÿ‘๏ธ PR Preview', '', @@ -64,7 +108,7 @@ jobs: '', '| Desktop | Mobile |', '|:-------:|:------:|', - `| ![Desktop](${ssBase}/desktop.png) | ![Mobile](${ssBase}/mobile.png) |`, + `| ![Desktop](${desktopUrl}) | ![Mobile](${mobileUrl}) |`, ].join('\n'); const { data: comments } = await github.rest.issues.listComments({ From 710d4e40a31c31704ec2acc27e6bef72df931357 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 21:57:43 +0000 Subject: [PATCH 3/4] fix: fix CSS/JS loading and screenshot ordering in preview workflow Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/25b83921-eeef-4909-9759-9db668d1e3d1 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- .github/workflows/deploy.yml | 6 ++++-- .github/workflows/preview.yml | 37 +++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 94cc553..67966aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,5 +54,7 @@ jobs: publish_dir: . # Preserve any existing PR preview directories across production deploys keep_files: true - # Exclude non-site files from the deployment - exclude_assets: '.github,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml,project-stats.yaml' + # Exclude non-site files from the deployment. + # Keep this list in sync with the exclude_assets in preview.yml + # (.gitignore and screenshots are additional preview-only exclusions). + exclude_assets: '.github,.gitignore,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml,project-stats.yaml' diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 6d40deb..745e2eb 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -33,6 +33,23 @@ jobs: - name: Capture desktop and mobile screenshots run: npm run screenshots + - name: Deploy PR preview to gh-pages branch + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 + 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 (keep in sync with deploy.yml). + # .gitignore is excluded so it is never deployed: if it lands in the gh-pages + # temp clone, peaceiris's `git add --all` would silently skip script.js, + # styles.css and the generated data files (all listed in .gitignore). + # Screenshots are excluded here because they are uploaded via the Content API + # in the next step; uploading before deploy would cause peaceiris to delete them. + # NOTE: deploy.yml shares the same base list minus .gitignore and screenshots. + exclude_assets: '.github,.gitignore,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml,project-stats.yaml,screenshots' + - name: Upload screenshots to GitHub id: upload-screenshots uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -55,7 +72,11 @@ jobs: owner, repo, path: ghPath, ref: branch, }); sha = data.sha; - } catch (_) { /* file doesn't exist yet */ } + } catch (err) { + // A 404 means the file doesn't exist yet โ€” that's expected on the + // first run. Re-throw anything else (auth errors, network failures). + if (err.status !== 404) throw err; + } await github.rest.repos.createOrUpdateFileContents({ owner, repo, @@ -70,20 +91,6 @@ jobs: `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${ghPath}`); } - - name: Remove .gitignore so built files are included in deploy - run: rm .gitignore - - - name: Deploy PR preview to gh-pages branch - uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 - 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 (keep in sync with deploy.yml; screenshots handled via Content API) - exclude_assets: '.github,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml,project-stats.yaml,screenshots' - - name: Post or update preview URL comment uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: From 69de6267a5e8a0be44e42bb17fd211e09dbc3bab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 22:53:49 +0000 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20correct=20deploy.yml=20comment=20?= =?UTF-8?q?=E2=80=94=20.gitignore=20is=20excluded=20here=20too,=20only=20s?= =?UTF-8?q?creenshots=20is=20preview-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/fdc540e4-74fa-4572-9140-f2a4eb85da07 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> --- .github/workflows/deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b0efc1a..340107e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,5 +35,8 @@ jobs: keep_files: true # Exclude non-site files from the deployment. # Keep this list in sync with the exclude_assets in preview.yml - # (.gitignore and screenshots are additional preview-only exclusions). + # (screenshots is an additional preview-only exclusion). + # .gitignore is excluded here too: if it lands in peaceiris's gh-pages temp + # clone, `git add --all` would silently skip script.js, styles.css and the + # generated data files (all listed in .gitignore). exclude_assets: '.github,.gitignore,node_modules,tests,scripts,package-lock.json,package.json,milestones.yaml,project-stats.yaml'