Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/take.yml
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] This is what test is failing on. check:asf-headers reports "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. Compare ci.yml:9. Fixing that one line turns the check green.

#
# 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 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] The assignability probe uses --silent under set -euo pipefail, so a user who cannot be assigned just fails the job. Because this is issue_comment-triggered, that failure only ever surfaces in the Actions tab, which contributors have no reason to visit — from their side they commented take and nothing happened, with no way to find out why.

The same applies to the two jq -e guards below: they are good verifications, but their failure is equally invisible. Worth posting a short comment on the issue for each failure path.

--header "X-GitHub-Api-Version: 2026-03-10" \
"$ASSIGNEES_ENDPOINT/$USER_LOGIN"

echo "Assigning issue $ISSUE_NUMBER to $USER_LOGIN"
gh api \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] POST /assignees appends rather than replaces — GitHub's own wording is "Users already assigned to an issue are not replaced." So if Alice has taken an issue, Bob commenting take leaves both assigned, which defeats the coordination this feature exists to provide (#3773 frames it as replacing "ask a committer to assign it to me").

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
Loading