forked from cockpit-project/cockpit-files
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.github: implement automatic recreate dependabot workflow
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
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
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; | ||
} |