Skip to content

Commit c57e8b9

Browse files
authored
ignoring pull request events (#2064)
* ignoring pull request events
1 parent cfc9663 commit c57e8b9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

backend/controllers/github.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
449449
}
450450
}()
451451

452+
if os.Getenv("DIGGER_IGNORE_PULL_REQUEST_EVENTS") == "1" {
453+
slog.Debug("Ignoring pull request event as DIGGER_IGNORE_PULL_REQUEST_EVENTS is set")
454+
return nil
455+
}
456+
452457
installationId := *payload.Installation.ID
453458
repoName := *payload.Repo.Name
454459
repoOwner := *payload.Repo.Owner.Login
@@ -1470,7 +1475,6 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
14701475
"issueNumber", issueNumber,
14711476
"impactedProjectCount", len(impactedProjectsForComment),
14721477
"allImpactedProjectsCount", len(allImpactedProjects),
1473-
14741478
)
14751479

14761480
jobs, coverAllImpactedProjects, err := generic.ConvertIssueCommentEventToJobs(repoFullName, actor, issueNumber, commentBody, impactedProjectsForComment, allImpactedProjects, config.Workflows, prBranchName, defaultBranch)
@@ -1483,7 +1487,7 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
14831487
commentReporterManager.UpdateComment(fmt.Sprintf(":x: Error converting event to jobs: %v", err))
14841488
return fmt.Errorf("error converting event to jobs")
14851489
}
1486-
1490+
14871491
slog.Info("Issue comment event converted to jobs successfully",
14881492
"issueNumber", issueNumber,
14891493
"jobCount", len(jobs),
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "Ignore pull request events"
3+
---
4+
5+
By default digger will run on every pull request event, figure out impacted projects, start jobs automatically
6+
and lock them. If you would like digger to ignore all pull requests by default and only react to digger plan / digger apply
7+
comments you can achieve this by setting the environment variable `DIGGER_IGNORE_PULL_REQUEST_EVENTS=1` on your selfhosted instance.

docs/mint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
"ce/howto/using-infracost",
108108
"ce/howto/using-opa-conftest",
109109
"ce/howto/using-terragrunt",
110-
"ce/howto/versioning"
110+
"ce/howto/versioning",
111+
"ce/howto/ignore-pull-request-events"
111112
]
112113
},
113114
{

0 commit comments

Comments
 (0)