Created
October 26, 2017 17:04
-
-
Save mjlescano/7bf62d3ed33a71b2e3326dff9c4c1427 to your computer and use it in GitHub Desktop.
Auto-merge GitHub PR when all checks passed
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
(() => { | |
const check = () => { | |
const status = document.querySelector('[data-combined-status]').dataset.combinedStatus | |
switch(status) { | |
case 'success': | |
const btn = document.querySelector('[data-details-container=".js-merge-pr"]') | |
if (!btn) { | |
alert('PR already merged.') | |
break | |
} else { | |
document.querySelector('.merge-branch-form.js-merge-pull-request').submit() | |
alert('PR merged :)') | |
break | |
} | |
case 'failure': | |
case 'pending': | |
if (window.automerger) clearTimeout(window.automerger) | |
window.automerger = setTimeout(check, 2000) | |
console.log('waiting for PR success') | |
break | |
default: | |
console.log('Unknown PR status (?)', status) | |
} | |
} | |
check() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment