Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/scripts/publish_pr_homepage_screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const sha = process.env.GITHUB_SHA;
const prNumber = process.env.PR_NUMBER;
const prHeadRef = process.env.PR_HEAD_REF;

if (!token) throw new Error('GITHUB_TOKEN or GH_TOKEN is required.');
if (!token) {
console.warn('Warning: GITHUB_TOKEN or GH_TOKEN is not set. Skipping PR screenshot publish step.');
process.exit(0);
}
if (!repository || !prNumber || !runId || !prHeadRef || !sha) {
throw new Error('Missing one or more required GitHub environment variables.');
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_frontend_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Publish screenshot to PR comment
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
env:
GITHUB_TOKEN: ${{ secrets.CRAZYGO_PAT }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_SHA: ${{ github.sha }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Background
The `PR Frontend E2E` workflow can fail in the `Publish screenshot to PR comment` step when no dedicated PAT-like secret is configured. The publish script currently throws immediately if neither `GITHUB_TOKEN` nor `GH_TOKEN` is present, which causes the job to fail even though screenshot generation itself succeeded.

# Goals
1. Prevent false-negative workflow failures caused by missing optional custom token configuration.
2. Keep PR screenshot publishing functional by using built-in GitHub token fallbacks.
3. Provide clearer script behavior when no token is available.

# Implementation Plan (phased)
## Phase 1: Workflow token fallback
- Update `.github/workflows/pr_frontend_e2e.yml` so the publish step injects `GITHUB_TOKEN` from a fallback chain (`GH_TOKEN`, then default `github.token`).

## Phase 2: Script resilience
- Update `.github/scripts/publish_pr_homepage_screenshot.js` to avoid hard failure when no token is available.
- Add a warning and exit successfully when token is missing so E2E validation/artifact upload still pass.

## Phase 3: Validation
- Run targeted checks (`node --check`) for the updated script and verify git diff for workflow/script consistency.

# Acceptance Criteria
1. A PR run without custom PAT configuration no longer fails solely due to missing token in screenshot publish step.
2. Screenshot publish step still attempts to post/update PR comment when any valid token is available.
3. If no token is present, logs show a clear warning and the step exits without failing the full workflow.
4. Updated script passes `node --check .github/scripts/publish_pr_homepage_screenshot.js`.
Loading