Skip to content

Commit

Permalink
Add ability to self-assign issues for non-committers (#21719)
Browse files Browse the repository at this point in the history
  • Loading branch information
damccorm authored Jun 8, 2022
1 parent a1c3d0c commit cd966ec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/self-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Assign or close an issue
on:
issue_comment:

jobs:
assign:
name: Take or close an issue
runs-on: ubuntu-latest
steps:
- run: |
BODY="$(jq '.comment.body' $GITHUB_EVENT_PATH)"
ISSUE_NUMBER="$(jq '.issue.number' $GITHUB_EVENT_PATH)"
LOGIN="$(jq '.comment.user.login' $GITHUB_EVENT_PATH | tr -d \")"
REPO="$(jq '.repository.full_name' $GITHUB_EVENT_PATH | tr -d \")"
ISSUE_JSON="$(jq '.issue' $GITHUB_EVENT_PATH)"
if [[ $BODY == *"$INPUT_TAKE"* ]]; then
echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
fi
if [[ $BODY == *"$INPUT_CLOSE"* ]]; then
echo "Closing issue $ISSUE_NUMBER"
echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER"
curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" -d '{"state":"closed"}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER
fi
shell: bash
env:
INPUT_TAKE: ".take-issue"
INPUT_CLOSE: ".close-issue"
GITHUB_TOKEN: ${{ github.token }}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ Questions can be asked on the [#beam channel of the ASF Slack](https://beam.apac
1. Find or create an issue in the [Beam repo](https://github.com/apache/beam/issues/new/choose).
Tracking your work in an issue will avoid duplicated or conflicting work, and provide
a place for notes. Later, your pull request will be linked to the issue as well.
2. Comment on the issue saying that you would like to work on it.
2. Comment ".take-issue" on the issue. This will cause the issue to be assigned to you.
When you've completed the issue, you can close it by commenting ".close-issue".
If you are a committer and would like to assign an issue to a non-committer, they must comment
on the issue first; please tag the user asking them to do so or to comment ".take-issue".
3. If your change is large or it is your first change, it is a good idea to
[discuss it on the [email protected] mailing list](https://beam.apache.org/community/contact-us/).
4. For large changes create a design doc
Expand Down

0 comments on commit cd966ec

Please sign in to comment.