Skip to content

Commit 340b702

Browse files
committed
do not scrape disabled, archived or not yet setup repos
Signed-off-by: Markus Blaschke <[email protected]>
1 parent 5aa9348 commit 340b702

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

metrics_github_workflows.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,17 @@ func (m *MetricsCollectorGithubWorkflows) Collect(callback chan<- func()) {
253253
}
254254

255255
for _, repo := range repositories {
256+
// skip archived or disabled repos
257+
if repo.GetArchived() || repo.GetDisabled() {
258+
continue
259+
}
260+
261+
// skip repos without default branch (not setup yet?)
262+
if repo.GetDefaultBranch() == "" {
263+
// repo doesn't have default branch
264+
continue
265+
}
266+
256267
// build custom properties
257268
propLabels := prometheus.Labels{}
258269
if len(Opts.GitHub.Repositories.CustomProperties) >= 1 {
@@ -277,11 +288,7 @@ func (m *MetricsCollectorGithubWorkflows) Collect(callback chan<- func()) {
277288
}
278289
repositoryMetric.AddInfo(labels)
279290

280-
if repo.GetDefaultBranch() == "" {
281-
// repo doesn't have default branch
282-
continue
283-
}
284-
291+
// get workflows
285292
workflows, err := m.getRepoWorkflows(org, repo.GetName())
286293
if err != nil {
287294
panic(err)

0 commit comments

Comments
 (0)