Skip to content

Commit

Permalink
19: Allow GitHub bots to use a PAT for authentication as well
Browse files Browse the repository at this point in the history
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Jun 27, 2019
1 parent a185823 commit 561d715
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -78,10 +78,15 @@ private Map<String, Host> parseHosts(JSONObject config, Path cwd) throws Configu
webUriReplacement = github.get("weburl").get("replacement").asString();
}

var keyFile = cwd.resolve(github.get("app").get("key").asString());
ret.put(entry.name(), HostFactory.createGitHubHost(uri, webUriPattern, webUriReplacement, keyFile.toString(),
github.get("app").get("id").asString(),
github.get("app").get("installation").asString()));
if (github.contains("app")) {
var keyFile = cwd.resolve(github.get("app").get("key").asString());
ret.put(entry.name(), HostFactory.createGitHubHost(uri, webUriPattern, webUriReplacement, keyFile.toString(),
github.get("app").get("id").asString(),
github.get("app").get("installation").asString()));
} else {
var pat = new PersonalAccessToken(github.get("username").asString(), github.get("pat").asString());
ret.put(entry.name(), HostFactory.createGitHubHost(uri, pat));
}
} else {
throw new ConfigurationError("Host " + entry.name());
}
Expand Down

0 comments on commit 561d715

Please sign in to comment.