chore(deps): update actions/checkout action to v7 #220
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
| name: PR beta publish prompt | |
| on: | |
| pull_request_target: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| comment: | |
| runs-on: ubuntu-latest | |
| # Keep this job capped at 10 minutes; never raise it unless explicitly asked. | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6.5.0 | |
| with: | |
| node-version: 24.x | |
| - name: Upsert beta publish comment | |
| uses: actions/github-script@v9.0.0 | |
| env: | |
| IS_SAME_REPO: ${{ github.event.pull_request.head.repo.full_name == github.repository && 'true' || 'false' }} | |
| with: | |
| script: | | |
| const marker = '<!-- pr-beta-publish -->'; | |
| const sameRepo = process.env.IS_SAME_REPO === 'true'; | |
| const pr = context.payload.pull_request; | |
| const body = sameRepo | |
| ? [ | |
| marker, | |
| '', | |
| '## Beta npm build', | |
| '', | |
| 'Maintainers can publish this PR to npm for fast testing.', | |
| '', | |
| 'Comment `/publish-beta` after the PR checks are green.', | |
| '', | |
| 'The workflow will:', | |
| '- publish a prerelease package on the `beta` tag', | |
| `- add a pinned \`pr-${pr.number}\` dist-tag for this exact PR build`, | |
| '- update this comment with the install command', | |
| '', | |
| 'Security note: beta publish is only enabled for branches inside this repository.', | |
| ].join('\n') | |
| : [ | |
| marker, | |
| '', | |
| '## Beta npm build', | |
| '', | |
| 'This PR comes from a fork, so beta publish is disabled for security.', | |
| '', | |
| 'If you need a beta package, move the branch into this repository first.', | |
| ].join('\n'); | |
| const { owner, repo } = context.repo; | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, | |
| repo, | |
| issue_number: pr.number, | |
| per_page: 100, | |
| }); | |
| const existing = comments.find((comment) => comment.user.type === 'Bot' && comment.body.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner, | |
| repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| return; | |
| } | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: pr.number, | |
| body, | |
| }); |