diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml new file mode 100644 index 00000000..24a8855a --- /dev/null +++ b/.github/workflows/auto-assign.yaml @@ -0,0 +1,34 @@ +name: Auto-assign issue on /attempt comment + +on: + issue_comment: + types: [created] + +jobs: + auto-assign: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const comment = context.payload.comment; + const issue = context.issue; + + if (comment.body.startsWith('/attempt')) { + if (!issue.assignee) { + github.issues.assignees.add({ + issue_number: issue.number, + assignees: [comment.user.login] + }); + await github.issues.createComment({ + issue_number: issue.number, + body: 'Assigned the issue to you!' + }); + } else { + await github.issues.createComment({ + issue_number: issue.number, + body: 'This issue is already assigned. Tag a maintainer if you need to take over.' + }); + } + }