Skip to content
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

Merged
merged 6 commits into from
Oct 19, 2023
Merged

feat: add support for blocking labels #24

merged 6 commits into from
Oct 19, 2023

Conversation

nickytonline
Copy link
Collaborator

@nickytonline nickytonline commented Oct 16, 2023

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:

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

@nickytonline nickytonline changed the title chore: added optional inputs for blocking labels feat: add support for blocking labels Oct 16, 2023
name: Assign issue to contributor
on:
Copy link
Collaborator Author

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

@nickytonline nickytonline marked this pull request as ready for review October 18, 2023 21:51
@nickytonline
Copy link
Collaborator Author

This is ready for review @bdougie @brandonroberts @jpmcb

Comment on lines +45 to +46
ISSUE_LABELS="$(jq -r '.issue.labels[].name' $GITHUB_EVENT_PATH)"
ISSUE_LABELS=$(echo "$ISSUE_LABELS" | jq -n --arg str "$ISSUE_LABELS" '$str | split("\n")')
Copy link
Collaborator Author

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.

action.yml Outdated Show resolved Hide resolved
@@ -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:
Copy link
Collaborator Author

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:
Copy link
Collaborator Author

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.

@bdougie
Copy link
Owner

bdougie commented Oct 18, 2023

@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.

@nickytonline
Copy link
Collaborator Author

@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. 😅

Copy link

@jpmcb jpmcb left a 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:

Screenshot 2023-10-18 at 4 26 04 PM

it started working as expected. It seems the default workflow permission for GITHUB_TOKEN is read only.

@jpmcb
Copy link

jpmcb commented Oct 18, 2023

The easiest way is to use the built-in ${{ secrets.GITHUB_TOKEN }} for authentication (as per the example below), but you'll need to ensure you've appropriately set the permissions for the GitHub Token so that your workflow can update Issues.

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.

@bdougie
Copy link
Owner

bdougie commented Oct 18, 2023

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.

@nickytonline
Copy link
Collaborator Author

nickytonline commented Oct 18, 2023

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).

Copy link
Owner

@bdougie bdougie left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block assigning if "needs-triage" or similar label is present on issue
3 participants