-
Notifications
You must be signed in to change notification settings - Fork 7
Preserve PR preview files in main branch deployment #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| name: PR Preview | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, closed] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| deploy-preview: | ||
| if: github.event.action != 'closed' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: ./frontend | ||
| run: npm install | ||
|
|
||
| - name: Build with PR base path | ||
| working-directory: ./frontend | ||
| run: npm run build -- --base=/ReproInventory/pr-previews/pr-${{ github.event.pull_request.number }}/ | ||
|
|
||
| - name: Deploy preview | ||
| uses: peaceiris/actions-gh-pages@v3 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./frontend/dist | ||
| publish_branch: gh-pages | ||
| destination_dir: pr-previews/pr-${{ github.event.pull_request.number }} | ||
| keep_files: true | ||
|
|
||
| - name: Post preview URL comment | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prNumber = context.payload.pull_request.number; | ||
| const previewUrl = `https://${{ github.repository_owner }}.github.io/ReproInventory/pr-previews/pr-${prNumber}/`; | ||
| const body = [ | ||
| '## 🔍 PR Preview', | ||
| '', | ||
| `**Preview URL:** ${previewUrl}`, | ||
| '', | ||
| `_Last updated: ${new Date().toUTCString()}_`, | ||
| ].join('\n'); | ||
|
|
||
| const comments = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| }); | ||
|
|
||
| const existing = comments.data.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, | ||
| }); | ||
| } | ||
|
|
||
| cleanup-preview: | ||
| if: github.event.action == 'closed' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout gh-pages branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: gh-pages | ||
|
|
||
| - name: Remove preview directory | ||
| run: | | ||
| PR_DIR="pr-previews/pr-${{ github.event.pull_request.number }}" | ||
| if [ -d "$PR_DIR" ]; then | ||
| rm -rf "$PR_DIR" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add -A | ||
| git commit -m "chore: remove PR preview for #${{ github.event.pull_request.number }}" | ||
| git push | ||
| else | ||
| echo "No preview directory found, nothing to clean up." | ||
| fi |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2185,7 +2185,10 @@ | |
| ], | ||
| "course_name": "Andy's brain book", | ||
| "url": "https://andysbrainbook.readthedocs.io/en/latest/", | ||
| "course_length": "NA", | ||
| "course_length": "1+ weeks", | ||
| "level": null, | ||
| "platform": null, | ||
| "keywords": null, | ||
| "instruction_medium": [ | ||
| "blog post", | ||
| "Hands-on tutorial / notebooks" | ||
|
|
@@ -2265,7 +2268,7 @@ | |
| "large-scale data", | ||
| "open data" | ||
| ], | ||
| "course_length": "NA", | ||
| "course_length": "1+ weeks", | ||
| "instruction_medium": null, | ||
| "delivery": null, | ||
| "language": null, | ||
|
|
@@ -2320,7 +2323,9 @@ | |
| "keywords": [ | ||
| "Machine Learning" | ||
| ], | ||
| "course_length": "NA", | ||
| "course_length": [ | ||
| "1+ weeks" | ||
| ], | ||
|
Comment on lines
+2326
to
+2328
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "course_length": "1+ weeks", |
||
| "instruction_medium": null, | ||
| "delivery": null, | ||
| "language": null, | ||
|
|
@@ -2373,8 +2378,6 @@ | |
| "Best Practices", | ||
| "Data Visualization" | ||
| ], | ||
| "course_length": null, | ||
| "instruction_medium": null, | ||
| "delivery": null, | ||
| "language": [ | ||
| "English" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>ReproInventory</title> | ||
| <script type="module" crossorigin src="/ReproInventory/assets/index-BfAUm7qF.js"></script> | ||
| <script type="module" crossorigin src="/ReproInventory/assets/index-zwxElJ_Y.js"></script> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build artifacts in the |
||
| <link rel="stylesheet" crossorigin href="/ReproInventory/assets/index-D0VB5yOL.css"> | ||
| </head> | ||
| <body> | ||
|
|
||
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.
These lines introduce duplicate keys (
level,platform,keywords) for entry ID 58. These keys are already defined with actual data later in the same object (starting at line 2199). While most JSON parsers will handle this by taking the last value, it is poor practice and makes the data file harder to maintain. Thesenullassignments should be removed from the source YAML file and the JSON regenerated.