Created
February 5, 2021 22:50
-
-
Save jpoehnelt/a9ef4d5ef71424deac179c54228974c6 to your computer and use it in GitHub Desktop.
Archive Dependabot Emails
This file contains 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
function archiveDependabotPullRequestsThatHaveBeenMerged() { | |
const threads = GmailApp.search('label:"inbox" from:dependabot[bot]'); | |
for (let thread of threads) { | |
if (isMerged(thread)) { | |
thread.moveToArchive(); | |
}; | |
} | |
} | |
const patterns = [/This PR is included in version/, /Merged .* into .*/, /Closed /]; | |
function isMerged(thread) { | |
const messages = thread.getMessages(); | |
if (messages.length > 1) { | |
for (let message of messages) { | |
for (let pattern of patterns) { | |
const match = message.getBody().match(pattern); | |
if (match) { | |
return true; | |
} | |
} | |
} | |
} | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment