From d397267d090ffd6fd3567aff608c5309048e15b4 Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Fri, 23 Oct 2026 09:24:21 -0700 Subject: [PATCH] Clean Dependabot PR descriptions automatically --- .github/workflows/clean-dependabot.yml | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/clean-dependabot.yml diff --git a/.github/workflows/clean-dependabot.yml b/.github/workflows/clean-dependabot.yml new file mode 100644 index 0000000..bfcca60 --- /dev/null +++ b/.github/workflows/clean-dependabot.yml @@ -0,0 +1,43 @@ +name: Clean Dependabot descriptions + +on: + pull_request_target: + types: [opened, reopened, synchronize, edited] + +permissions: + pull-requests: write + +concurrency: + group: clean-dependabot-${{ github.event.pull_request.number }} + +jobs: + clean: + if: github.event.pull_request.user.login == 'dependabot[bot]' + runs-on: ubuntu-26.04 + steps: + # This privileged workflow only edits PR metadata; do not run PR code here. + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const params = { + ...context.repo, + pull_number: context.issue.number, + }; + const { data: pr } = await github.rest.pulls.get(params); + if (pr.state !== 'open') return; + + const before = pr.body ?? ''; + const after = before + .split(/\nDependabot will resolve any conflicts\b/)[0] + .replace(/]*>[\s\S]*?<\/details>/gi, '') + .replace(//gi, '') + .replace(/\n{3,}/g, '\n\n') + .trim(); + + if (!after || /