Skip to content

Commit

Permalink
Enforce color for triage/backport labels
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Jan 5, 2024
1 parent a43cb85 commit ee66326
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/io/quarkus/bot/SetTriageBackportLabelColor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.quarkus.bot;

import java.io.IOException;

import jakarta.inject.Inject;

import org.jboss.logging.Logger;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHLabel;

import io.quarkiverse.githubapp.ConfigFile;
import io.quarkiverse.githubapp.event.Label;
import io.quarkus.bot.config.Feature;
import io.quarkus.bot.config.QuarkusGitHubBotConfig;
import io.quarkus.bot.config.QuarkusGitHubBotConfigFile;
import io.quarkus.bot.util.Labels;

public class SetTriageBackportLabelColor {

private static final Logger LOG = Logger.getLogger(SetTriageBackportLabelColor.class);

@Inject
QuarkusGitHubBotConfig quarkusBotConfig;

private static final String TRIAGE_BACKPORT_LABEL_COLOR = "7fe8cd";

void setAreaLabelColor(@Label.Created GHEventPayload.Label labelPayload,
@ConfigFile("quarkus-github-bot.yml") QuarkusGitHubBotConfigFile quarkusBotConfigFile) throws IOException {
if (!Feature.SET_TRIAGE_BACKPORT_LABEL_COLOR.isEnabled(quarkusBotConfigFile)) {
return;
}

GHLabel label = labelPayload.getLabel();

if (!label.getName().startsWith(Labels.TRIAGE_BACKPORT_PREFIX)
|| TRIAGE_BACKPORT_LABEL_COLOR.equalsIgnoreCase(label.getColor())) {
return;
}

if (!quarkusBotConfig.isDryRun()) {
label.set().color(TRIAGE_BACKPORT_LABEL_COLOR);
} else {
LOG.info("Label " + label.getName() + " - Set color: #" + TRIAGE_BACKPORT_LABEL_COLOR);
}
}
}
1 change: 1 addition & 0 deletions src/main/java/io/quarkus/bot/config/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum Feature {
NOTIFY_QE,
QUARKUS_REPOSITORY_WORKFLOW,
SET_AREA_LABEL_COLOR,
SET_TRIAGE_BACKPORT_LABEL_COLOR,
TRIAGE_ISSUES_AND_PULL_REQUESTS,
TRIAGE_DISCUSSIONS,
PUSH_TO_PROJECTS,
Expand Down

0 comments on commit ee66326

Please sign in to comment.