From 81c35a5ea8d99cf4764e11a333904454cb5419d3 Mon Sep 17 00:00:00 2001 From: Jeff Bishop Date: Mon, 4 May 2026 12:01:20 -0700 Subject: [PATCH] fix: update-or-create comments, failure fallback, concurrency for Challenge 10 --- .github/workflows/autograder-local-commit.yml | 67 ++++++++++++++++++- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autograder-local-commit.yml b/.github/workflows/autograder-local-commit.yml index a3e7f51..cbfa0d9 100644 --- a/.github/workflows/autograder-local-commit.yml +++ b/.github/workflows/autograder-local-commit.yml @@ -11,6 +11,10 @@ permissions: contents: read pull-requests: write +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: check-local-commit: name: Verify Local Commit Exists @@ -66,13 +70,70 @@ jobs: 'Your local Git workflow is working. Well done!' ].join('\n'); } + const MARKER = '## Challenge 10:'; try { - await github.rest.issues.createComment({ + const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: context.issue.number, - body + issue_number: context.issue.number }); + const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body + }); + } } catch (error) { console.error('Could not post Challenge 10 result:', error.message); } + + - name: Post workflow error notice + if: failure() + uses: actions/github-script@v7 + with: + script: | + const MARKER = '## Challenge 10:'; + const body = [ + '## Challenge 10: Check could not complete', + '', + 'The automated local commit check ran into an unexpected error. Your work is not affected.', + 'Keep going and ask your facilitator, or mention @facilitator in a comment.', + '', + '---', + '*Automated message from Learning Room Bot.*' + ].join('\n'); + try { + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body + }); + } + } catch (err) { + console.error('Could not post error notice:', err.message); + }