-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce color for triage/backport labels
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/io/quarkus/bot/SetTriageBackportLabelColor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters