Skip to content

Instantly share code, notes, and snippets.

@mjlescano
Created October 26, 2017 17:04
Show Gist options
  • Save mjlescano/7bf62d3ed33a71b2e3326dff9c4c1427 to your computer and use it in GitHub Desktop.
Save mjlescano/7bf62d3ed33a71b2e3326dff9c4c1427 to your computer and use it in GitHub Desktop.
Auto-merge GitHub PR when all checks passed
(() => {
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