Skip to content

Instantly share code, notes, and snippets.

@jpoehnelt
Created February 5, 2021 22:50
Show Gist options
  • Save jpoehnelt/a9ef4d5ef71424deac179c54228974c6 to your computer and use it in GitHub Desktop.
Save jpoehnelt/a9ef4d5ef71424deac179c54228974c6 to your computer and use it in GitHub Desktop.
Archive Dependabot Emails
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