Skip to content

Commit 751379c

Browse files
committed
Rename GitHub token env var
1 parent 808f9ff commit 751379c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.env.sample

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# if `GITHUB_API_TOKEN` is not set here, the token can also be stored in `~/.gitconfig`
2-
GITHUB_API_TOKEN=MUST_BE_CONFIGURED
1+
# if `GITHUB_TOKEN` is not set here, the token can also be stored in `~/.gitconfig`
2+
GITHUB_TOKEN=MUST_BE_CONFIGURED
33
DATABASE_URL=MUST_BE_CONFIGURED
44
GITHUB_WEBHOOK_SECRET=MUST_BE_CONFIGURED
55
# for logging, refer to this document: https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html
@@ -8,6 +8,6 @@ GITHUB_WEBHOOK_SECRET=MUST_BE_CONFIGURED
88

99
# If you are running a bot on non-rustbot account,
1010
# this allows to configure that username which the bot will respond to.
11-
# For example write blahblahblah here, if you want for this bot to
11+
# For example write blahblahblah here, if you want for this bot to
1212
# respond to @blahblahblah claim.
1313
# TRIAGEBOT_USERNAME=CAN_BE_CONFIGURED

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The general overview of what you will need to do:
4040
4. Configure the `.env` file:
4141

4242
1. Copy `.env.sample` to `.env`
43-
2. `GITHUB_API_TOKEN`: This is a token needed for Triagebot to send requests to GitHub. Go to GitHub Settings > Developer Settings > Personal Access Token, and create a new token. The `repo` permission should be sufficient.
43+
2. `GITHUB_TOKEN`: This is a token needed for Triagebot to send requests to GitHub. Go to GitHub Settings > Developer Settings > Personal Access Token, and create a new token. The `repo` permission should be sufficient.
4444
If this is not set, Triagebot will also look in `~/.gitconfig` in the `github.oauth-token` setting.
4545
3. `DATABASE_URL`: This is the URL to the database. See [Configuring a database](#configuring-a-database).
4646
4. `GITHUB_WEBHOOK_SECRET`: Enter the secret you entered in the webhook above.

src/github.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,12 @@ impl RequestSend for RequestBuilder {
20352035
/// Finds the token in the user's environment, panicking if no suitable token
20362036
/// can be found.
20372037
pub fn default_token_from_env() -> String {
2038+
match std::env::var("GITHUB_TOKEN") {
2039+
Ok(v) => return v,
2040+
Err(_) => (),
2041+
}
2042+
2043+
// kept for retrocompatibility but usage is discouraged and will be deprecated
20382044
match std::env::var("GITHUB_API_TOKEN") {
20392045
Ok(v) => return v,
20402046
Err(_) => (),
@@ -2045,7 +2051,7 @@ pub fn default_token_from_env() -> String {
20452051
Err(_) => (),
20462052
}
20472053

2048-
panic!("could not find token in GITHUB_API_TOKEN or .gitconfig/github.oath-token")
2054+
panic!("could not find token in GITHUB_TOKEN, GITHUB_API_TOKEN or .gitconfig/github.oath-token")
20492055
}
20502056

20512057
fn get_token_from_git_config() -> anyhow::Result<String> {

0 commit comments

Comments
 (0)