-
Notifications
You must be signed in to change notification settings - Fork 330
feat: add github action to self-assign the issue #3774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # 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/unassign the issue via `take` or `untake` comment | ||
| on: | ||
| issue_comment: | ||
| types: created | ||
|
|
||
| permissions: | ||
| issues: write | ||
|
|
||
| jobs: | ||
| issue_assign: | ||
| runs-on: ubuntu-slim | ||
| if: (!github.event.issue.pull_request) && (github.event.comment.body == 'take' || github.event.comment.body == 'untake') | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.issue.number }} | ||
| queue: max | ||
| steps: | ||
| - name: Take or untake issue | ||
| env: | ||
| COMMENT_BODY: ${{ github.event.comment.body }} | ||
| ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
| USER_LOGIN: ${{ github.event.comment.user.login }} | ||
| REPO: ${{ github.repository }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| ASSIGNEES_ENDPOINT="repos/$REPO/issues/$ISSUE_NUMBER/assignees" | ||
|
|
||
| if [[ "$COMMENT_BODY" == "take" ]]; then | ||
| gh api --silent \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] The assignability probe uses The same applies to the two |
||
| --header "X-GitHub-Api-Version: 2026-03-10" \ | ||
| "$ASSIGNEES_ENDPOINT/$USER_LOGIN" | ||
|
|
||
| echo "Assigning issue $ISSUE_NUMBER to $USER_LOGIN" | ||
| gh api \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Suggest reading the current assignees first and refusing when the list is non-empty and does not already contain the commenter, with a comment saying who holds it. |
||
| --method POST \ | ||
| --header "X-GitHub-Api-Version: 2026-03-10" \ | ||
| "$ASSIGNEES_ENDPOINT" \ | ||
| --field "assignees[]=$USER_LOGIN" | | ||
| jq -e --arg user "$USER_LOGIN" \ | ||
| '.assignees | map(.login) | index($user) != null' >/dev/null | ||
| elif [[ "$COMMENT_BODY" == "untake" ]]; then | ||
| echo "Unassigning issue $ISSUE_NUMBER from $USER_LOGIN" | ||
| gh api \ | ||
| --method DELETE \ | ||
| --header "X-GitHub-Api-Version: 2026-03-10" \ | ||
| "$ASSIGNEES_ENDPOINT" \ | ||
| --field "assignees[]=$USER_LOGIN" | | ||
| jq -e --arg user "$USER_LOGIN" \ | ||
| '.assignees | map(.login) | index($user) == null' >/dev/null | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] This is what
testis failing on.check:asf-headersreports "1 file(s) carry the ASF license text in a form this policy does not render" — the only difference from every other workflow in the repo is the indentation here: the canonical form is five spaces,# http://www.apache.org/licenses/LICENSE-2.0. Compareci.yml:9. Fixing that one line turns the check green.