fix(worker): start with a repository-only token
The start-up check read the token's account with GET /user, which needs the read:user scope. A token with only repository scope, which is all the worker needs, got 403 and the worker exited in a restart loop. On 403 it now names the commit author from BOT_NAME (default gbr-bot) and still checks push access on the games repo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
425c242ae7
commit
0c868f7bac
3 files changed
+30
-1
No files matched your search
@@ -60,7 +60,12 @@ func (c *workerConfig) checkBot() error {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
if err := c.giteaGet("/user", &user); err != nil {
|
||||
return fmt.Errorf("GITEA_TOKEN: %w", err)
|
||||
if !strings.HasPrefix(err.Error(), "HTTP 403") {
|
||||
return fmt.Errorf("GITEA_TOKEN: %w", err)
|
||||
}
|
||||
// A repository-only token (all the worker needs) may not read its own account: name the author from
|
||||
// BOT_NAME instead. Whether it can push is still checked below.
|
||||
user.Login = envOr("BOT_NAME", "gbr-bot")
|
||||
}
|
||||
var repo struct {
|
||||
Permissions struct {
|
||||
|
||||
Reference in new issue
Block a user