-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autobot: Automate Merging Dependabot PRs #65
Comments
Using my DOM script from #1 as the starting point. This works manually in Chrome/FF dev tools: function run() {
document
.querySelectorAll(".octicon-git-pull-request.color-fg-open")[0]
.closest(".notification-list-item-link")
.click();
setTimeout(() => {
document
.querySelectorAll(".octicon-file-diff")[0]
.closest(".tabnav-tab")
.click();
setTimeout(() => {
document.querySelectorAll(".js-reviews-toggle")[0].click();
var text = "Thanks @dependabot 🤖 👌";
document.getElementById("pull_request_review_body").value = text;
document.querySelectorAll('[value="approve"]')[0].click();
document.querySelectorAll("button.float-left")[2].click();
next();
}, 5000);
}, 5000);
}
run();
function next() {
setTimeout(() => {
document.querySelectorAll(".hx_create-pr-button")[0].click();
document.querySelectorAll(".js-merge-commit-button")[0].click();
setTimeout(() => {
document.querySelectorAll('[title="Done"]')[0].click();
run();
}, 4000);
}, 4000);
} Due to the full-page-refresh when submitting a PR review which is both server and client rendered 🙄 |
OK. not going to waste any more time on this. It's definitely a distraction!! But when I need the script it's better to run it in two stages: document
.querySelectorAll(".octicon-git-pull-request.color-fg-open")[0]
.closest(".notification-list-item-link")
.click();
setTimeout(() => {
document
.querySelectorAll(".octicon-file-diff")[0]
.closest(".tabnav-tab")
.click();
setTimeout(() => {
document.querySelectorAll(".js-reviews-toggle")[0].click();
var text = "Thanks @dependabot 🤖 👌";
document.getElementById("pull_request_review_body").value = text;
document.querySelectorAll('[value="approve"]')[0].click();
document.querySelectorAll("button.float-left")[2].click();
}, 3000);
}, 3000); Followed by: document.querySelectorAll(".hx_create-pr-button")[0].click();
document.querySelectorAll(".js-merge-commit-button")[0].click();
setTimeout(() => {
document.querySelectorAll('[title="Done"]')[0].click();
}, 4000); because the DOM loading is incredibly unreliable! |
Quick demo: autobot-demo.mov |
Once you have run both script blocks once you can use the up arrow and enter keys to repeat. ♻️ |
Reading: https://violentmonkey.github.io/get-it/ Given that Microsoft already know everything I'm doing on GitHub ... And using it as my GitHub Notifications browser ... 💭 |
Let's come back to this. |
Top tip. if you don't quite the Chrome App your DevTools Console history maintains any scripts/code you have run so even though I had closed the tab I could still retrieve the script from history. just used it. so glad I wrote it. let's see how long the DOM attributes/classes last before GH inevitably does another re-design. 🙄 |
Easy enough, the number of buttons on the page was reduced from 3 to 2 so the index for the "Submit review" button is now document
.querySelectorAll(".octicon-git-pull-request.color-fg-open")[0]
.closest(".notification-list-item-link")
.click();
setTimeout(() => {
document
.querySelectorAll(".octicon-file-diff")[0]
.closest(".tabnav-tab")
.click();
setTimeout(() => {
document.querySelectorAll(".js-reviews-toggle")[0].click();
var text = "Thanks @dependabot 🤖 👌";
document.getElementById("pull_request_review_body").value = text;
document.querySelectorAll('[value="approve"]')[0].click();
document.querySelectorAll("button.float-left")[1].click();
}, 2000);
}, 2000); I would still like to make the whole script run as one but now is not the time to be messing with that because of network latency ... ⏳ |
var links = document
.querySelectorAll(".octicon-git-pull-request.color-fg-open");
links[links.length - 1].closest(".notification-list-item-link").click();
setTimeout(() => {
document
.querySelectorAll(".octicon-file-diff")[0]
.closest(".tabnav-tab")
.click();
setTimeout(() => {
document.querySelectorAll(".js-reviews-toggle")[0].click();
var text = "Thanks @dependabot 🤖 👌";
document.getElementById("pull_request_review_body").value = text;
document.querySelectorAll('[value="approve"]')[0].click();
document.querySelectorAll("button.float-left")[1].click();
}, 2000);
}, 2000); |
document.querySelectorAll(".hx_create-pr-button")[0].click();
document.querySelectorAll(".js-merge-commit-button")[0].click();
setTimeout(() => {
document.querySelectorAll('[aria-label="Done"]')[0].click();
}, 2000); |
Attempt single script: var links = document
.querySelectorAll(".octicon-git-pull-request.color-fg-open");
links[links.length - 1].closest(".notification-list-item-link").click();
setTimeout(() => {
document
.querySelectorAll(".octicon-file-diff")[0]
.closest(".tabnav-tab")
.click();
setTimeout(() => {
document.querySelectorAll(".js-reviews-toggle")[0].click();
var text = "Thanks @dependabot 🤖 👌";
document.getElementById("pull_request_review_body").value = text;
document.querySelectorAll('[value="approve"]')[0].click();
document.querySelectorAll("button.float-left")[1].click();
// merge:
setTimeout(() => {
document.querySelectorAll(".hx_create-pr-button")[0].click();
document.querySelectorAll(".js-merge-commit-button")[0].click();
setTimeout(() => {
document.querySelectorAll('[aria-label="Done"]')[0].click();
}, 1000);
}, 2000);
}, 2000);
}, 2000); |
If someone has merged a bunch of @dependabot PRs e.g: Then the above script breaks because the document
.querySelectorAll(".notification-list-item-link")[0]
.click()
setTimeout(() => {
document
.querySelectorAll(".octicon-file-diff")[0]
.closest(".tabnav-tab")
.click();
setTimeout(() => {
document.querySelectorAll(".js-reviews-toggle")[0].click();
var text = "Thanks @dependabot 🤖 👌";
document.getElementById("pull_request_review_body").value = text;
document.querySelectorAll("button.float-left")[1].click();
setTimeout(() => {
document.querySelectorAll('[aria-label="Done"]')[0].click();
}, 3000);
}, 2000);
}, 2000); |
Followed by:
# Context:
We have quite a few
Elixir/Phoenix
projects ... github.com/dwyl?q=language=elixirso when a random dependency is patched and Dependabot creates Pull Requests to update it,
we get this kind of thing:
I don't want to merge them all without supervision because I want to be informed of the updates.
But I do want to a generic script I can use to automate.
Think of it as "supervised automation" 😜
The text was updated successfully, but these errors were encountered: