Federated via graft
0

Configure Feed

Select the types of activity you want to include in your feed.

graft-source / internal / sync / authint.go
1.2 kB 36 lines
1package sync 2 3import ( 4 "strings" 5 6 "graft/internal/forgejo" 7) 8 9// HasAuthorizedIntegration reports whether fc's repository has a Forgejo 10// Actions workflow configured to push directly to targetHost via 11// Authorized Integrations (a job with `enable-openid-connect: true` whose 12// body references targetHost). Detected by scanning 13// .forgejo/workflows/*.yml — there's no admin API to query the trust 14// relationship itself, so this is the only signal available from a 15// regular repo token's perspective. False on any error (missing 16// directory, no access, ...): absence of evidence is treated as "not 17// configured", never as a reason to fail the sync. 18func HasAuthorizedIntegration(fc *forgejo.Client, targetHost string) bool { 19 names, err := fc.ListWorkflowFiles() 20 if err != nil { 21 return false 22 } 23 for _, name := range names { 24 if !strings.HasSuffix(name, ".yml") && !strings.HasSuffix(name, ".yaml") { 25 continue 26 } 27 content, err := fc.GetFileContent(".forgejo/workflows/" + name) 28 if err != nil { 29 continue 30 } 31 if strings.Contains(content, "enable-openid-connect") && strings.Contains(content, targetHost) { 32 return true 33 } 34 } 35 return false 36}