fix obs staging bot

This commit is contained in:
2025-02-10 15:14:29 +01:00
parent 61d9359ce3
commit 2f38e559d1
2 changed files with 26 additions and 11 deletions

View File

@@ -551,17 +551,30 @@ func pollWorkNotifications(giteaHost string) {
if data != nil {
for _, notification := range data {
switch notification.Subject.Type {
case "Pull":
processPullNotification(gitea, notification)
default:
gitea.SetNotificationRead(notification.ID)
log.Println(notification.ID, "--", notification.Subject)
if !ListPullNotificationsOnly && (ProcessIDOnly < 0 || ProcessIDOnly == notification.ID) {
switch notification.Subject.Type {
case "Pull":
processPullNotification(gitea, notification)
default:
gitea.SetNotificationRead(notification.ID)
}
}
}
}
}
var ListPullNotificationsOnly bool
var ProcessIDOnly int64
var Debug bool
func main() {
flag.BoolVar(&Debug, "debug", false, "One-shot run. Use for debugging")
flag.BoolVar(&ListPullNotificationsOnly, "list-notifications-only", false, "Only lists notifications without acting on them")
flag.Int64Var(&ProcessIDOnly, "id", -1, "Process only the specific ID and ignore the rest. Use for debugging")
flag.Parse()
failOnError(common.RequireGiteaSecretToken(), "Cannot find GITEA_TOKEN")
failOnError(common.RequireObsSecretToken(), "Cannot find OBS_USER and OBS_PASSWORD")
@@ -571,7 +584,9 @@ func main() {
for {
pollWorkNotifications(*giteaHost)
if Debug {
break
}
time.Sleep(10 * time.Minute)
}
}