integrations / slack

Bring your code to the conversations you care about with the GitHub and Slack integration
https://slack.github.com/
MIT License
2.98k stars 468 forks source link

Add repo filters to subscribe command for entire organization #1778

Open boonedoggle opened 9 months ago

boonedoggle commented 9 months ago
          @gimenete when I subscribe to the whole organisation, and then try to unsubscribe from a specific repo, I get an error saying I'm not subscribed to those repos. 

/github subscribe Org-name /github unsubscribe Org-name/repo

You're not currently subscribed to Org-name/repo Use /github subscribe Org-name/repo to subscribe.

It happens with multiple repos in the org. I am not even sure from these errors whether I'm subscribed to any of the repos in the org. When I try:

/github subscribe list

I get:

Subscribed to the following accounts Org-name

And the only repos listed as subscribed are the ones I've listed manually. I am trying to subscribe to the whole org to catch newly created repos, and exclude non-dev repos.

Originally posted by @Jessicawatsonmiller in https://github.com/integrations/slack/issues/391#issuecomment-433257461

boonedoggle commented 9 months ago

For orgs with a large number of repos, it is convenient to subscribe to the entire organization. That being said, there may be a number of reasons to exclude a few repositories. It would be great if something like the following command worked:

/github subscribe Org-name omit:"noisy-repo"
archon810 commented 3 months ago

This would be a killer feature. I recently asked about it here https://github.com/integrations/slack/discussions/1842 but received no replies. Now I see it's not supported yet based on this ticket and #391.

Please make this work, Github, it's such an important missing feature.

ColeDCrawford commented 1 month ago

This is killing us too. I don't want to have to manually subscribe a channel to 100 repos to exclude one noisy one.

t4k commented 2 weeks ago

I put together an AppleScript to do the resubscribing for me.

First I needed a list of repositories which I got via the GitHub CLI:

gh repo list my_organization --json nameWithOwner --jq .[].nameWithOwner --limit 1000 --no-archived

Then I copied and pasted the output into a text editor where I could quickly prepend and append each line with the text for the GitHub bot in Slack (this could have been done in the shell and included in the output as well if I wanted to think about it more):

/github subscribe my_organization/repository1 workflows reviews comments branches commits:* discussions
/github subscribe my_organization/repository2 workflows reviews comments branches commits:* discussions
/github subscribe my_organization/repositoryETC workflows reviews comments branches commits:* discussions

Finally I ran the AppleScript through Automator on macOS to do the copy and paste between TextEdit (or anything else) and Slack:

repeat 315 times

    tell application "TextEdit" to activate
    tell application "System Events"
        tell process "TextEdit"
            key code 124 using {shift down, command down}
            keystroke "c" using command down
            key code 123 using command down
            key code 125
        end tell
    end tell

    delay 1

    tell application "Slack" to activate
    tell application "System Events"
        tell process "Slack"
            keystroke "v" using command down
            delay 1
            keystroke return
        end tell
    end tell

    delay 5

end repeat

The key codes represent arrow keys. 124: right arrow, 123: left arrow, 125: down arrow.

Also, I created a notifier that will post new repositories to our Slack channel so that we remember to subscribe them: https://github.com/caltechlibrary/congenial-octo-machine