-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: add support for blocking labels #24
feat: add support for blocking labels #24
Conversation
name: Assign issue to contributor | ||
on: |
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.
Looks like prettier cleaned up some trailing white space
This is ready for review @bdougie @brandonroberts @jpmcb |
ISSUE_LABELS="$(jq -r '.issue.labels[].name' $GITHUB_EVENT_PATH)" | ||
ISSUE_LABELS=$(echo "$ISSUE_LABELS" | jq -n --arg str "$ISSUE_LABELS" '$str | split("\n")') |
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.
Gets the issue labels as an array.
@@ -14,6 +14,17 @@ inputs: | |||
description: 'Message to contributors if issue is already assigned' | |||
required: false | |||
default: 'The issue you are trying to assign to yourself is already assigned.' | |||
|
|||
blockingLabels: |
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.
By default, no blocking labels
required: false | ||
default: '' | ||
|
||
blockingLabelsMessage: |
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.
A default message about blocking labels that can be customized.
@nickytonline are you still getting the "message": "Resource not accessible by integration"? I know silently changes what permissions the default token has. Curious if labels are included or another feature is not accessible from the default token. |
The permission error isn't related to the issue labels. Those I can read fine. I get that error when trying to add a comment or assign a user. That's why I think it's unrelated to my changes. I could be wrong though. 😅 |
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.
This lgtm.
I think I discovered your token permission problem. I created my own test repo: https://github.com/jpmcb/test-take but I was also getting permission errors (on both nickytonline/take-action
and bdougie/take-action
But once I updated this Actions setting:
it started working as expected. It seems the default workflow permission for GITHUB_TOKEN
is read only.
Looks like this is documented in the README 😓 😅 https://github.com/bdougie/take-action?tab=readme-ov-file#setup I totally breezed by that when investigating the token issue ha. |
That's it. Permissions need to verify set now. |
@bdougie, I updated the permissions for actions on my test repo and all good now, e.g. https://github.com/nickytonline/test-take-action/actions/runs/6567914467 And here’s an automated comment telling me it’s blocked by a label, nickytonline/test-take-action#3 (comment). |
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.
This looks great. Look forward to adding this version to our projects.
Adds support for blocking labels. Adding blocking labels is optional, so the GitHub action works as it did previously if no blocking labels are configured.
Existing scenarios:
There are no blocking labels on an issue:
The user can be assigned the issue assuming it isn't already assigned. See https://github.com/nickytonline/test-take-action/actions/runs/6566343428/job/17837978699
The user cannot be assigned the issue if someone is already assigned. See https://github.com/nickytonline/test-take-action/actions/runs/6566879299/job/17838484505
There is a blocking label on an issue:
There is more than one blocking label on an issue:
Sample workflow for this workflow in a repository with blocking labels enabled
name: "Assign issues with .take" on: issue_comment: types: - created - edited jobs: take-issue: name: Disable take issue runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: take an issue uses: bdougie/take-action@main with: issueCurrentlyAssignedMessage: Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. token: ${{ secrets.GITHUB_TOKEN }} + blockingLabels: needs triage,blocked
I'm pretty sure this is unrelated as I didn't change anything for how the GitHub API calls work, but I think I have the action misconfigured as I get this error when trying to use the API. Not sure why it's not finding my
secrets.GITHUB_TOKEN
"message": "Resource not accessible by integration",
Closes #20