-
Notifications
You must be signed in to change notification settings - Fork 6
ci: publish PR web previews #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gac0812
merged 4 commits into
1024XEngineer:MVP
from
gac0812:codex/ci-pr-web-preview-fix
Aug 1, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: PR Preview (same-repository branches) | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, closed] | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: pr-preview-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| explain-fork-limit: | ||
| name: Explain fork preview limitation | ||
| if: github.event.pull_request.head.repo.full_name != github.repository | ||
| permissions: | ||
| contents: read | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Record why deployment is skipped | ||
| run: echo "Fork preview deployment is intentionally disabled because pull_request workflows cannot safely grant write credentials to untrusted fork code." | ||
|
|
||
| deploy-preview: | ||
| name: Deploy same-repository web preview | ||
| if: github.event.pull_request.head.repo.full_name == github.repository | ||
| permissions: | ||
| contents: write | ||
| deployments: read | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.action == 'closed' && github.event.pull_request.base.sha || github.event.pull_request.head.sha }} | ||
|
|
||
| - name: Set up Node.js | ||
| if: github.event.action != 'closed' | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20.20.2 | ||
| cache: npm | ||
| cache-dependency-path: frontend/package-lock.json | ||
|
|
||
| - name: Install frontend dependencies | ||
| if: github.event.action != 'closed' | ||
| working-directory: frontend | ||
| run: npm ci | ||
|
|
||
| - name: Export interactive web preview | ||
| if: github.event.action != 'closed' | ||
| working-directory: frontend | ||
| env: | ||
| EXPO_PUBLIC_USE_FAKE_WS: 'true' | ||
| EXPO_PUBLIC_WS_URL: '' | ||
| TIMEFLOW_PREVIEW_BASE_URL: /${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.number }} | ||
| run: npx expo export --platform web --dev --output-dir dist | ||
|
|
||
| - name: Deploy preview and comment on PR | ||
| uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1 | ||
| with: | ||
| source-dir: frontend/dist | ||
| preview-branch: gh-pages | ||
| umbrella-dir: pr-preview | ||
| action: auto | ||
| wait-for-pages-deployment: true | ||
| comment: true | ||
| qr-code: true | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1 @@ | ||
| # TimeFlow | ||
|
|
||
| ## Frontend map setup | ||
|
|
||
| Copy `frontend/.env.example` to `frontend/.env` and set | ||
| `EXPO_PUBLIC_BAIDU_MAP_AK` to a Baidu Maps browser-side AK. Enable JavaScript | ||
| API v4 for that AK in the Baidu Maps console and add the development and | ||
| production web origins to its Referer whitelist. Native builds render the | ||
| same JavaScript API in a WebView, so its configured `baseUrl` | ||
| (`https://timeflow.local/`) must also be allowed by the AK configuration. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| module.exports = ({ config }) => { | ||
| const previewBaseUrl = process.env.TIMEFLOW_PREVIEW_BASE_URL?.trim(); | ||
|
|
||
| if (!previewBaseUrl) return config; | ||
|
|
||
| return { | ||
| ...config, | ||
| experiments: { | ||
| ...config.experiments, | ||
| baseUrl: previewBaseUrl, | ||
| }, | ||
| }; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition skips the entire job whenever the PR head repository is a fork, which includes this PR. As a result, fork PRs never export, deploy, or receive a preview comment. If fork previews are intended to be supported, use a trigger/checkout design that preserves token safety while allowing the preview; otherwise this workflow should document that limitation rather than presenting itself as a general PR preview.