Skip to content

feat(ci): Create PRs with ruff fixes automatically #2

feat(ci): Create PRs with ruff fixes automatically

feat(ci): Create PRs with ruff fixes automatically #2

name: Close Ruff Auto-fix PR
on:
pull_request:
types: [closed]
jobs:
close-autofix-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Close matching Ruff auto-fix PR
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const sourcePrNumber = context.payload.pull_request.number;
const head = `${owner}:ci/ruff-autofix/pr-${sourcePrNumber}`;
const { data: pulls } = await github.rest.pulls.list({
owner,
repo,
state: "open",
head,
per_page: 100,
});
for (const pr of pulls) {
await github.rest.pulls.update({
owner,
repo,
pull_number: pr.number,
state: "closed",
});
}