|
| 1 | +name: Comment on fixed issues |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [closed] |
| 6 | + |
| 7 | +jobs: |
| 8 | + add-comment: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Get associated PRs |
| 12 | + id: get-prs |
| 13 | + uses: actions/github-script@v7 |
| 14 | + with: |
| 15 | + script: | |
| 16 | + const issue_number = context.payload.issue.number; |
| 17 | +
|
| 18 | + // Search for PRs that mention the issue number |
| 19 | + const query = `repo:${context.repo.owner}/${context.repo.repo} is:pr is:merged linked:issue-${issue_number}`; |
| 20 | + const searchResult = await github.rest.search.issuesAndPullRequests({ |
| 21 | + q: query |
| 22 | + }); |
| 23 | +
|
| 24 | + if (searchResult.data.items.length === 0) { |
| 25 | + console.log('No merged PRs found for this issue'); |
| 26 | + return; |
| 27 | + } |
| 28 | +
|
| 29 | + // Get the first merged PR number |
| 30 | + const prNumber = searchResult.data.items[0].number; |
| 31 | + console.log(`Found merged PR #${prNumber} associated with issue #${issue_number}`); |
| 32 | +
|
| 33 | + // Set output for the next step |
| 34 | + core.setOutput('pr_number', prNumber); |
| 35 | + core.setOutput('has_pr', 'true'); |
| 36 | +
|
| 37 | + - name: Add comment to issue |
| 38 | + if: steps.get-prs.outputs.has_pr == 'true' |
| 39 | + uses: actions/github-script@v7 |
| 40 | + with: |
| 41 | + script: | |
| 42 | + const issueNumber = context.payload.issue.number; |
| 43 | + const prNumber = steps.get-prs.outputs.pr_number; |
| 44 | +
|
| 45 | + const commentBody = `This fix or feature will be available in the next npm release of Base UI. |
| 46 | +
|
| 47 | + In the meantime, you can try it out on our Canary release channel: |
| 48 | +
|
| 49 | + npm i https://pkg.pr.new/@base-ui-components/react@${prNumber}`; |
| 50 | +
|
| 51 | + await github.rest.issues.createComment({ |
| 52 | + owner: context.repo.owner, |
| 53 | + repo: context.repo.repo, |
| 54 | + issue_number: issueNumber, |
| 55 | + body: commentBody |
| 56 | + }); |
| 57 | +
|
| 58 | + console.log(`Added comment to issue #${issueNumber}`); |
0 commit comments