-
Notifications
You must be signed in to change notification settings - Fork 7
Address Benjie's review feedback #56
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
base: magicmark-patch-6
Are you sure you want to change the base?
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,27 @@ | ||
| // Minimizes previous deploy-preview comments so only the latest is visible. | ||
| // Called from preview-deploy.yml via actions/github-script. | ||
|
|
||
| export default async function run({ github, context, prNumber }) { | ||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| }); | ||
|
|
||
| await Promise.all( | ||
| comments | ||
| .filter((c) => c.body.includes("<!-- deploy-preview -->")) | ||
|
Member
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. When people reply to GitHub notification emails it often includes a copy of the previous message - if it copies this from the bot's message then their comment will also be hidden. Suggest you also filter by author. |
||
| .map((c) => | ||
| github.graphql( | ||
| ` | ||
| mutation($id: ID!) { | ||
| minimizeComment(input: { subjectId: $id, classifier: OUTDATED }) { | ||
| minimizedComment { isMinimized } | ||
| } | ||
| } | ||
| `, | ||
| { id: c.node_id } | ||
| ) | ||
| ) | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,14 @@ jobs: | |
| - name: Checkout wrangler config | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| ref: main | ||
| sparse-checkout: | | ||
| wrangler.jsonc | ||
| .github/scripts | ||
|
|
||
| # Security: actions/download-artifact handles zip extraction safely | ||
| # (immune to zip-slip), and the artifact only contains static HTML/CSS/JS | ||
| # built by the unprivileged preview-build workflow. | ||
| - name: Download build artifact | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | ||
| with: | ||
|
|
@@ -45,34 +50,23 @@ jobs: | |
| fi | ||
| echo "number=$PR_NUM" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # Security: Wrangler is configured for static asset serving only (see | ||
| # wrangler.jsonc). The uploaded content is pre-built HTML/CSS/JS with no | ||
| # server-side execution capability. | ||
| - name: Deploy preview to Cloudflare Workers | ||
| id: deploy | ||
| uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| command: versions upload --preview-alias "pr-${{ steps.pr.outputs.number }}" --message "PR #${{ steps.pr.outputs.number }} preview" | ||
| command: versions upload --preview-alias "pr-${{ steps.pr.outputs.number }}" --message "PR #${{ steps.pr.outputs.number }} preview (${{ github.event.workflow_run.head_sha }})" | ||
|
Member
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. Does wranger versions upload do a pure upload, or might it read any configuration/run any scripts/be influenced by any content from within |
||
|
|
||
| - name: Hide old deploy preview comments | ||
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 | ||
| with: | ||
| script: | | ||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: ${{ steps.pr.outputs.number }} | ||
| }); | ||
| await Promise.all( | ||
| comments | ||
| .filter(c => c.body.includes('<!-- deploy-preview -->')) | ||
| .map(c => github.graphql(` | ||
| mutation($id: ID!) { | ||
| minimizeComment(input: { subjectId: $id, classifier: OUTDATED }) { | ||
| minimizedComment { isMinimized } | ||
| } | ||
| } | ||
| `, { id: c.node_id })) | ||
| ); | ||
| const { default: run } = await import('${{ github.workspace }}/.github/scripts/hide-old-deploy-comments.mjs'); | ||
| await run({ github, context, prNumber: ${{ steps.pr.outputs.number }} }); | ||
|
|
||
| - name: Comment on PR (success) | ||
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 | ||
|
|
||
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.
per_page defaults to 30, so this will only find the comments to update if in the first 30.