@@ -16,6 +16,7 @@ import (
1616 "os"
1717 "os/signal"
1818 "path/filepath"
19+ "strconv"
1920 "strings"
2021 "sync"
2122 "syscall"
@@ -205,12 +206,37 @@ func main() {
205206 serverPort = defaultPort
206207 }
207208
208- // Allow environment variables to override flags for OAuth credentials
209- if envClientID := os .Getenv ("GITHUB_CLIENT_ID" ); envClientID != "" {
210- * clientID = envClientID
209+ // Allow environment variables to override empty flag values
210+ if * appID == defaultAppID {
211+ if envAppID := os .Getenv ("GITHUB_APP_ID" ); envAppID != "" {
212+ if id , err := strconv .Atoi (envAppID ); err == nil {
213+ * appID = id
214+ }
215+ }
216+ }
217+
218+ if * clientID == defaultClientID || * clientID == "" {
219+ if envClientID := os .Getenv ("GITHUB_CLIENT_ID" ); envClientID != "" {
220+ * clientID = envClientID
221+ }
222+ }
223+
224+ if * clientSecret == "" {
225+ if envSecret := os .Getenv ("GITHUB_CLIENT_SECRET" ); envSecret != "" {
226+ * clientSecret = envSecret
227+ }
211228 }
212- if envSecret := os .Getenv ("GITHUB_CLIENT_SECRET" ); envSecret != "" {
213- * clientSecret = envSecret
229+
230+ if * redirectURI == defaultRedirectURI || * redirectURI == "" {
231+ if envRedirectURI := os .Getenv ("OAUTH_REDIRECT_URI" ); envRedirectURI != "" {
232+ * redirectURI = envRedirectURI
233+ }
234+ }
235+
236+ if * allowedOrigins == "" {
237+ if envAllowedOrigins := os .Getenv ("ALLOWED_ORIGINS" ); envAllowedOrigins != "" {
238+ * allowedOrigins = envAllowedOrigins
239+ }
214240 }
215241
216242 // Initialize rate limiter
0 commit comments