Skip to content

Commit

Permalink
.github: implement automatic recreate dependabot workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Oct 11, 2024
1 parent 24180cc commit 760f8e0
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/rebase-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: rebase-dependabot
on:
push:
branches: [ main ]

jobs:
dependabot_rebase:
runs-on: ubuntu-latest
steps:
- name: Recreate open dependabot pull-requests
uses: actions/github-script@v7
with:
script: |
const { repo: { owner, repo } } = context;
const pull_requests = await github.rest.pulls.list({
owner,
repo,
state: 'open',
sort: 'long-running',
direction: 'asc',
})
for (const { number: pull_number, user } of pull_requests.data) {
if (user.login !== 'dependabot[bot]') {
continue;
}
console.log(`Inspecting pull request #${pull_number}`);
const pull_request = await github.rest.pulls.get({
owner,
repo,
pull_number,
});
console.log(pull_request);
// Skip dependabot pull requests which are being worked on
if (pull_request.data.commits !== 1) {
console.log('Skipping pull request as it is being worked on');
continue;
}
if (pull_request.data.mergeable === true) {
console.log('Skipping mergeable pull request');
continue;
}
if (pull_request.data.mergeable === null) {
console.log('Skipping pull request with unknown mergeable state');
continue;
}
// Comment to re-create the PR and set no-test
github.rest.issues.addLabels({
issue_number: pull_number,
owner,
repo,
labels: ['no-test']
});
// Only process one dependabot at a time.
break;
}

0 comments on commit 760f8e0

Please sign in to comment.