- Notifications
You must be signed in to change notification settings - Fork 4.4k
Test PR preview deployment#1168
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
- Add Hebrew translations for GitHub cheat sheets - Add submodule vs subtree cheat sheet in Hebrew - Add subversion migration guide in Hebrew - Add AGENTS.md documentation - Update index.html to include new resources 💘 Generated with Crush Assisted-by: Claude Sonnet 4.5 via Crush <[email protected]>
Enables automatic preview deployments for PRs from forks, streamlining translation review and content editing approval. Features: - Builds Jekyll site for fork PRs only (excludes internal PRs) - Deploys to fork's GitHub Pages under pr-{number}/ directory - Auto-creates gh-pages branch if needed - Posts preview URL as PR comment - Uses fine-grained PAT with minimal permissions (Contents + Pages) Setup guide included for fork owners. 💖 Generated with Crush Assisted-by: Claude Sonnet 4.5 via Crush <[email protected]>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.
Pull request overview
This PR adds Hebrew translations for Git/GitHub documentation and introduces a new PR preview deployment workflow for fork contributions.
- Adds complete Hebrew language support with three translated cheat sheets
- Introduces automated PR preview deployment workflow for fork-based contributions
- Adds comprehensive documentation for AI agents and PR preview setup
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
index.html | Adds Hebrew language links for all three cheat sheet types (Git, SVN migration, Submodules vs Subtrees) |
downloads/he/github-git-cheat-sheet.md | New Hebrew translation of the GitHub Git cheat sheet with RTL text support |
downloads/he/subversion-migration.md | New Hebrew translation of the SVN to Git migration guide with RTL text support |
downloads/he/submodule-vs-subtree-cheat-sheet.md | New Hebrew translation of the submodules vs subtrees comparison guide with RTL text support |
.github/workflows/pr-preview.yml | New GitHub Actions workflow that automatically deploys PR previews to fork's GitHub Pages for review |
.github/workflows/PR_PREVIEW_SETUP.md | Documentation explaining how fork owners can set up the PR preview deployment feature |
AGENTS.md | Comprehensive guide for AI agents working with the training-kit repository, covering project structure, commands, and workflows |
README.md | Adds test line for PR preview workflow verification (should be removed before merge) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| ref: ${{github.event.pull_request.head.sha }} | ||
| - name: Set up Node | ||
| uses: actions/setup-node@v3 |
CopilotAINov 30, 2025
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.
The workflow uses actions/setup-node@v3 which is outdated. Consider updating to @v4 for better performance and the latest features.
| uses: actions/setup-node@v3 | |
| uses: actions/setup-node@v4 |
| run: npm install | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@ece82769428359c077b5a5eaff268902a303c101 |
CopilotAINov 30, 2025
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.
The SHA used for ruby/setup-ruby action appears to be a specific commit hash. While this provides security through pinning, consider using a tagged version (e.g., @v1) for better maintainability, or add a comment explaining why this specific SHA is needed.
| uses: ruby/setup-ruby@ece82769428359c077b5a5eaff268902a303c101 | |
| uses: ruby/setup-ruby@v1 |
| JEKYLL_ENV: production | ||
| - name: Deploy to fork's GitHub Pages | ||
| uses: peaceiris/actions-gh-pages@v3 |
CopilotAINov 30, 2025
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.
The workflow uses peaceiris/actions-gh-pages@v3. Consider updating to @v4 if available, or verify that v3 is still the recommended version for this action.
| uses: peaceiris/actions-gh-pages@v3 | |
| uses: peaceiris/actions-gh-pages@v4 |
| # PR Preview Setup Guide | ||
| This workflow automatically builds and deploys preview versions of the site for pull requests coming from forks. This is especially useful for translation reviews and content editing. | ||
| ## How it works | ||
| 1. When a PR is opened from a fork, the workflow builds the Jekyll site | ||
| 2. The built site is deployed to the fork's GitHub Pages under `pr-{number}/` | ||
| 3. A comment is posted on the PR with the preview URL | ||
| 4. The preview updates automatically when new commits are pushed | ||
| ## Setup Required (For Fork Owners) | ||
| To enable preview deployments from your fork, you need to: | ||
| ### 1. Create a Fine-Grained Personal Access Token | ||
| - Go to GitHub Settings → Developer settings → Personal access tokens → **Fine-grained tokens** | ||
| - Click "Generate new token" | ||
| - Configure the token: | ||
| -**Token name:**`PR Preview Deploy` | ||
| -**Expiration:** Choose your preferred expiration (90 days, 1 year, custom, or no expiration) | ||
| -**Resource owner:** Select yourself (the fork owner) | ||
| -**Repository access:** Select "Only select repositories" | ||
| - Choose your fork repository (e.g., `your-username/training-kit`) | ||
| -**Permissions → Repository permissions:** | ||
| - ✅ **Contents:** Read and write (required to push to gh-pages branch) | ||
| - ✅ **Pages:** Read and write (required to manage GitHub Pages) | ||
| - ✅ **Metadata:** Read-only (automatically included) | ||
| - Click "Generate token" | ||
| -**Copy the token immediately** (you won't see it again) | ||
| ### 2. Add the token to your fork's secrets | ||
| - Go to your fork's Settings → Secrets and variables → Actions | ||
| - Click "New repository secret" | ||
| - Name: `PREVIEW_DEPLOY_TOKEN` | ||
| - Value: Paste the fine-grained personal access token you created | ||
| - Click "Add secret" | ||
| ### 3. Enable GitHub Pages in your fork (after first deployment) | ||
| After the first PR preview is deployed, the gh-pages branch will be created automatically. Then: | ||
| - Go to your fork's Settings → Pages | ||
| - Under "Source", select "Deploy from a branch" | ||
| - Select **gh-pages** branch and **/ (root)** folder | ||
| - Click Save | ||
| - GitHub Pages will be available at: `https://your-username.github.io/training-kit/` | ||
| ## Preview URL Format | ||
| Previews will be available at: | ||
| ``` | ||
| https://{fork-owner}.github.io/{repo-name}/pr-{number}/ | ||
| ``` | ||
| For example: | ||
| ``` | ||
| https://johndoe.github.io/training-kit/pr-42/ | ||
| ``` | ||
| ## Security | ||
| - Only runs for PRs from forks (not internal PRs) | ||
| - Uses `pull_request_target` to run in the context of the base repository | ||
| - Checks out the specific PR SHA to build exactly what was submitted | ||
| - Uses fine-grained PAT with minimal required permissions (Contents and Pages only) | ||
| - Each fork owner controls their own credentials and deployment | ||
| ## Notes | ||
| - The gh-pages branch is created automatically on first deployment | ||
| - The first deployment may take a few minutes for GitHub Pages to become available | ||
| - Previews persist until manually deleted from the gh-pages branch | ||
| - Each PR gets its own isolated preview directory | ||
| - You can clean up old previews by deleting directories from the gh-pages branch |
CopilotAINov 30, 2025
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.
[nitpick] Documentation files are typically placed in a docs/ directory or at the repository root, not within the .github/workflows/ directory. Consider moving this setup guide to either .github/PR_PREVIEW_SETUP.md or docs/PR_PREVIEW_SETUP.md for better organization.
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v3 |
CopilotAINov 30, 2025
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.
The workflow uses actions/checkout@v3 which is outdated. Consider updating to @v4 for better performance and the latest features.
| uses: actions/checkout@v3 | |
| uses: actions/checkout@v4 |
| user_name: 'github-actions[bot]' | ||
| user_email: 'github-actions[bot]@users.noreply.github.com' | ||
| # Create gh-pages branch if it doesn't exist | ||
| force_orphan: true |
CopilotAINov 30, 2025
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.
Setting force_orphan: true will create a new orphan branch on every deployment, discarding all previous history. This may not be the intended behavior for PR previews. Consider using force_orphan: false to maintain deployment history, or add a comment explaining why history should be discarded.
| force_orphan: true | |
| force_orphan: false |
| This means you can use the content and code in this repository except for GitHub trademarks in your projects. | ||
| When you contribute to this repository you are doing so under the above licenses. | ||
| Testing PR preview workflow |
CopilotAINov 30, 2025
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 test line should be removed before merging. It appears to be a temporary addition for testing purposes and doesn't belong in the production README.
| Testing PR preview workflow |
| - On push to main: Builds with Jekyll and deploys to GitHub Pages | ||
| - Uses Node 16 and Ruby (version from Gemfile) | ||
| -**codeql.yml**: Security scanning | ||
| -**dependency-review.yml**: Dependency security checks |
CopilotAINov 30, 2025
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.
The CI/CD section should be updated to include documentation about the new pr-preview.yml workflow that is being added in this PR. This will help future contributors understand all available workflows.
| -**dependency-review.yml**: Dependency security checks | |
| -**dependency-review.yml**: Dependency security checks | |
| -**pr-preview.yml**: Builds and deploys a preview of the site for pull requests, allowing contributors to view changes before merging. |
| if [ "${{github.event.pull_request.head.repo.full_name }}" != "${{github.repository }}" ]; then | ||
| echo "is-fork=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "is-fork=false" >> $GITHUB_OUTPUT | ||
| fi |
CopilotAINov 30, 2025
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.
The fork detection logic may fail if github.event.pull_request.head.repo is null (which happens when the source branch is deleted). Consider adding a null check to prevent workflow failures:
if [ "${{github.event.pull_request.head.repo.full_name }}" != "" ] && [ "${{github.event.pull_request.head.repo.full_name }}" != "${{github.repository }}" ]; then| with: | ||
| # This requires the fork to have a fine-grained PAT as a secret | ||
| # The fork owner needs to set up PREVIEW_DEPLOY_TOKEN in their repo secrets | ||
| personal_token: ${{secrets.PREVIEW_DEPLOY_TOKEN }} |
CopilotAINov 30, 2025
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.
The workflow will fail if PREVIEW_DEPLOY_TOKEN secret is not set in the fork. Consider adding error handling or a conditional check to provide a more user-friendly error message. Alternatively, document this requirement more prominently in the workflow comment at the top of the file.
Complements existing PR preview with automatic fork-based previews. Two-stage review process: 1. Fork Preview (fork-preview.yml) - Runs automatically on push to fork branches - No approval needed - Uses GITHUB_TOKEN (no PAT required) - URL: https://{fork-owner}.github.io/training-kit/preview/{branch}/ - Best for: self-review and team discussion 2. PR Preview (pr-preview.yml) - Runs on PR creation (existing workflow) - Requires maintainer approval - Uses fine-grained PAT - URL: https://{fork-owner}.github.io/training-kit/pr-{number}/ - Best for: maintainer review Benefits: - Contributors can iterate quickly without waiting for approval - Translation teams can review before formal PR submission - Maintainers review already-vetted content - Both workflows optional and complementary 💖 Generated with Crush Assisted-by: Claude Sonnet 4.5 via Crush <[email protected]>
Testing the new PR preview workflow for fork contributions