Repository navigation
fix: preserve cached indexing results #109
Workflow file for this run
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
| # .github/workflows/pr-comment.yml | ||
|
Check warning on line 1 in .github/workflows/pr-comment.yml
|
||
| name: PR Status Comment | ||
| on: | ||
| pull_request_target: | ||
| types: [opened, synchronize, reopened] | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
| checks: read | ||
| concurrency: | ||
| group: pr-comment-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| comment: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Post or update status comment | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const pr = context.payload.pull_request; | ||
| const sha = pr.head.sha; | ||
| // Retry a few times in case checks are still running | ||
| async function getCompletedQuickChecks(maxTries = 6, delayMs = 10000) { | ||
| for (let i = 0; i < maxTries; i++) { | ||
| const { data } = await github.rest.checks.listForRef({ owner, repo, ref: sha }); | ||
| const run = data.check_runs.find(r => r.name === 'Quick Checks'); | ||
| if (run && run.status === 'completed') return run; | ||
| await new Promise(r => setTimeout(r, delayMs)); | ||
| } | ||
| return null; | ||
| } | ||
| const run = await getCompletedQuickChecks(); | ||
| if (!run) { | ||
| core.info('No completed "Quick Checks" run found. Skipping comment.'); | ||
| return; | ||
| } | ||
| const outcome = run.conclusion; // success | failure | neutral | cancelled | timed_out | action_required | stale | skipped | ||
| const message = `${outcome === 'success' ? '✅' : '❌'} Quick checks ${outcome}`; | ||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner, repo, issue_number: pr.number, | ||
| }); | ||
| const botComment = comments.find(c => | ||
| c.user.type === 'Bot' && /Quick checks/.test(c.body) | ||
| ); | ||
| if (botComment) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, repo, comment_id: botComment.id, body: message | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner, repo, issue_number: pr.number, body: message | ||
| }); | ||
| } | ||