Created
February 7, 2019 16:48
-
-
Save garaemon/7e6ffaf4393bea4ed386c5cf2a25c25d to your computer and use it in GitHub Desktop.
Notify pull requests closed today on ros/rosdistro to slack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime, timedelta | |
| import slackweb | |
| from github import Github | |
| REPO = 'ros/rosdistro' | |
| g = Github() | |
| repo = g.get_repo('ros/rosdistro') | |
| pulls = repo.get_pulls(state='closed', sort='created', direction='desc') | |
| now = datetime.now() | |
| oneday = timedelta(days=1) | |
| today_prs = [] | |
| for p in pulls: | |
| diff = now - p.created_at | |
| if diff > oneday: | |
| break | |
| else: | |
| today_prs.append(p) | |
| text = '{} prs were closed today on {}\n'.format(len(today_prs), REPO) | |
| for pr in today_prs: | |
| text +='* <{}|{}>\n'.format(pr.html_url, pr.title) | |
| slack = slackweb.Slack(url='https://hooks.slack.com/services/XXXXXX') | |
| slack.notify(text=text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment