Skip to content

Commit 1964bf4

Browse files
authored
feat(dependabot-auto-triage): close PRs related to dismissed alerts (#1161)
* feat(dependabot-auto-triage): close PRs related to dismissed alerts * feat(dependabot-auto-triage): make close-prs an optional input * feat(dependabot-auto-triage): add tests for close-prs input * chore(dependabot-auto-triage): document close-prs input * chore(dependabot-auto-triage): run prettier * Add check to skip PRs that are associated with valid alerts * Run prettier * Fix ESLint
1 parent 89ae65c commit 1964bf4

File tree

6 files changed

+663
-30
lines changed

6 files changed

+663
-30
lines changed

actions/dependabot-auto-triage/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
ksonnet/lib/argo-workflows/charts/**/*.json
6161
dismissal-reason: "not_used"
6262
dismissal-comment: "These dependencies are not used in production and pose no risk"
63+
close-prs: "true" # Optional: close associated Dependabot PRs
6364
```
6465
6566
<!-- x-release-please-end-version -->
@@ -73,12 +74,15 @@ jobs:
7374
| `paths` | Multi-line list of glob patterns to match manifest paths to dismiss | Yes | N/A |
7475
| `dismissal-comment` | Default comment to add when dismissing alerts | No | `Auto-dismissed based on manifest path configuration` |
7576
| `dismissal-reason` | Default reason for dismissal (options: `fix_started`, `inaccurate`, `no_bandwidth`, `not_used`, `tolerable_risk`) | No | `not_used` |
77+
| `close-prs` | Whether to close associated Dependabot pull requests before dismissing alerts | No | `false` |
7678

7779
### How It Works
7880

7981
1. The action fetches all open Dependabot alerts for the repository
8082
2. For each alert, it checks if the manifest path matches any of the provided glob patterns
81-
3. If the path matches a pattern, it dismisses the alert with the specified reason and comment
83+
3. If `close-prs` is enabled, it fetches associated pull requests for matching alerts
84+
4. For each matching alert, it optionally closes the associated pull request first (if `close-prs` is true)
85+
5. It then dismisses the alert with the specified reason and comment
8286

8387
### Glob Pattern Syntax
8488

@@ -100,6 +104,7 @@ To use this action, you need:
100104
1. A GitHub App with the following permissions:
101105
- Repository permissions:
102106
- **Dependabot alerts**: Read & Write
107+
- **Pull requests**: Read & Write (only required if `close-prs` is set to `true`)
103108

104109
2. The GitHub App needs to be installed on your repository or organization
105110

actions/dependabot-auto-triage/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
required: false
2424
default: "not_used"
2525
# Options: 'fix_started', 'inaccurate', 'no_bandwidth', 'not_used', 'tolerable_risk'
26+
close-prs:
27+
description: "Whether to close associated pull requests when dismissing alerts"
28+
required: false
29+
default: "false"
2630

2731
runs:
2832
using: "composite"
@@ -47,6 +51,7 @@ runs:
4751
INPUT_PATHS: ${{ inputs.paths }}
4852
INPUT_DISMISSAL_COMMENT: ${{ inputs.dismissal-comment }}
4953
INPUT_DISMISSAL_REASON: ${{ inputs.dismissal-reason }}
54+
INPUT_CLOSE_PRS: ${{ inputs.close-prs }}
5055
NODE_ENV: "production"
5156
run: |
5257
bun run src/index.ts

actions/dependabot-auto-triage/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"test": "bun test"
1212
},
1313
"dependencies": {
14+
"@octokit/graphql": "^9.0.1",
1415
"@octokit/request-error": "7.0.0",
1516
"@octokit/rest": "22.0.0",
1617
"minimatch": "10.0.3"

0 commit comments

Comments
 (0)