|
14 | 14 | steps: |
15 | 15 | - name: "Checkout" |
16 | 16 | uses: actions/checkout@v4 |
17 | | - # - name: "Search for Repository" |
18 | | - |
| 17 | + - name: "Search for Repository" |
| 18 | + uses: actions/github-script@v7 |
| 19 | + with: |
| 20 | + script: | |
| 21 | + const owner = context.repo.owner; |
| 22 | + const repo = "pxt-common-packages"; // your repo name |
| 23 | + const issueText = context.payload.issue.title + " " + context.payload.issue.body; |
| 24 | +
|
| 25 | + // Build GitHub search query |
| 26 | + const query = `repo:${owner}/${repo} "${issueText}"`; |
| 27 | +
|
| 28 | + const results = await github.rest.search.code({ q: query }); |
| 29 | +
|
| 30 | + let message = ""; |
| 31 | + if (results.data.total_count === 0) { |
| 32 | + message = "No related files or code were found in this repository."; |
| 33 | + } else { |
| 34 | + message = `Found **${results.data.total_count}** related matches:\n`; |
| 35 | + for (const item of results.data.items) { |
| 36 | + message += `- \`${item.path}\`\n`; |
| 37 | + } |
| 38 | + } |
| 39 | +
|
| 40 | + core.setOutput("message", message); |
| 41 | + - name: Comment on issue with results |
| 42 | + uses: actions/github-script@v7 |
| 43 | + with: |
| 44 | + script: | |
| 45 | + const body = `### 🔍 Automated Search Results\n${steps.search.outputs.message}`; |
| 46 | + await github.rest.issues.createComment({ |
| 47 | + owner: context.repo.owner, |
| 48 | + repo: context.repo.repo, |
| 49 | + issue_number: context.issue.number, |
| 50 | + body |
| 51 | + }); |
| 52 | + env: |
| 53 | + token: ${{secrets.GITHUB_TOKEN}} |
0 commit comments