From ad8692fe24b98f7723f2d0f7c83bafc3f383a021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20No=C3=ABl?= <21990816+philippemnoel@users.noreply.github.com> Date: Fri, 20 Sep 2024 11:08:53 -0400 Subject: [PATCH] ci: [Phil + Weijun] Create GitHub Actions workflow to allow users to self-assign issues (#1691) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Noël <21990816+philippemnoel@users.noreply.github.com> Co-authored-by: Weijun-H --- .github/workflows/assign-github-issue.yml | 64 +++++++++++++++++++++++ CONTRIBUTING.md | 18 ++++++- 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/assign-github-issue.yml diff --git a/.github/workflows/assign-github-issue.yml b/.github/workflows/assign-github-issue.yml new file mode 100644 index 000000000..2518d7a97 --- /dev/null +++ b/.github/workflows/assign-github-issue.yml @@ -0,0 +1,64 @@ +# workflows/assign-github-issue.yml +# +# Assign GitHub Issue +# Automatically assign an issue to the commenter if they use the '/take' command. + +name: Assign GitHub Issue + +on: + issue_comment: + types: [created] + +# Required to assign the issue to the commenter +permissions: + issues: write + +concurrency: + group: assign-github-issue-${{ github.workflow }}-${{ github.event.issue.number }} + cancel-in-progress: true + +jobs: + assign-github-issue: + name: Assign GitHub Issue to Commenter + runs-on: depot-ubuntu-latest-2 + if: !github.event.issue.pull_request && contains(github.event.comment.body, '/take') + + steps: + - name: Check if Commenter Can Be Assigned + id: check_assignee + run: | + HTTP_CODE=$(curl -X GET \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -o /dev/null -w '%{http_code}\n' -s \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees/${{ github.event.comment.user.login }}") + + if [ "$HTTP_CODE" -eq "204" ]; then + echo "can_assign=true" >> $GITHUB_OUTPUT + else + echo "can_assign=false" >> $GITHUB_OUTPUT + fi + + - name: Assign GitHub Issue + if: steps.check_assignee.outputs.can_assign == 'true' + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees" + + echo "Issue #${{ github.event.issue.number }} assigned to ${{ github.event.comment.user.login }}" + + - name: Notify of Assignment Failure + if: steps.check_assignee.outputs.can_assign == 'false' + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.name, + body: '@${{ github.event.comment.user.login }} Unable to assign this issue to you. You may not have the necessary permissions.' + }) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 78168556c..d9e8c1fc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,6 @@ # **Contributing to ParadeDB** -Welcome! We're excited that you're interested in contributing to ParadeDB and want -to make the process as smooth as possible. +Welcome! We're excited that you're interested in contributing to ParadeDB and want to make the process as smooth as possible. ## Technical Info @@ -10,6 +9,21 @@ conventions to follow when submitting changes. If you have any questions not cov in this document, please reach out to us in the [ParadeDB Community Slack](https://join.slack.com/t/paradedbcommunity/shared_invite/zt-2lkzdsetw-OiIgbyFeiibd1DG~6wFgTQ) or via [email](mailto:support@paradedb.com). +### Claiming GitHub Issues + +This repository has a workflow to automatically assign issues to new contributors. This ensures that you don't need approval +from a maintainer to pick an issue. + +1. Before claiming an issue, ensure that: + +- It's not already assigned to someone else +- There are no comments indicating ongoing work + +2. To claim an unassigned issue, simply comment `/take` on the issue. This will automatically assign the issue to you. + +If you find yourself unable to make progress, don't hesitate to seek help in the issue comments or in the [ParadeDB Community Slack](https://join.slack.com/t/paradedbcommunity/shared_invite/zt-2lkzdsetw-OiIgbyFeiibd1DG~6wFgTQ). If you no longer wish to +work on the issue(s) you self-assigned, please use the `unassign me` link at the top of the issue(s) page to release it. + ### Development Workflow ParadeDB is structured as a monorepo containing our Postgres extensions, our Docker setup, and our development tools for benchmarking and testing.