Skip to content

Commit 8c6aa4d

Browse files
authored
Merge pull request #18 from OpenElements/Daniel-Dev
Env
2 parents 2fa1bd8 + 0812945 commit 8c6aa4d

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/com/openelements/issues/services/GitHubClient.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.jspecify.annotations.Nullable;
1414
import org.slf4j.Logger;
1515
import org.slf4j.LoggerFactory;
16+
import org.springframework.beans.factory.annotation.Value;
1617
import org.springframework.http.ResponseEntity;
1718
import org.springframework.stereotype.Service;
1819
import org.springframework.web.client.RestClient;
@@ -22,7 +23,6 @@
2223
public class GitHubClient {
2324

2425
private final static Logger log = LoggerFactory.getLogger(GitHubClient.class);
25-
public static final String GITHUB_TOKEN = "GITHUB_TOKEN";
2626
public static final String GITHUB_API_URL = "https://api.github.com";
2727
public static final String HTTP_ACCEPT = "Accept";
2828
public static final String GITHUB_V_3_JSON = "application/vnd.github.v3+json";
@@ -35,11 +35,10 @@ public class GitHubClient {
3535
* Default constructor that initializes the GitHub client with the base URL and headers.
3636
* It retrieves the GitHub token from the environment variable GITHUB_TOKEN.
3737
*/
38-
public GitHubClient() {
38+
public GitHubClient(@Value("${github.token}") String githubToken) {
3939
Builder builder = RestClient.builder()
4040
.baseUrl(GITHUB_API_URL)
4141
.defaultHeader(HTTP_ACCEPT, GITHUB_V_3_JSON);
42-
final String githubToken = System.getenv("GITHUB_TOKEN");
4342
if (githubToken != null && !githubToken.isBlank()) {
4443
log.info("Using GitHub token for API authentication");
4544
builder = builder.defaultHeader("Authorization", "Bearer " + githubToken);

src/main/resources/application.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ hacktoberfest:
88
repo: hedera-solo-action
99

1010

11+
github:
12+
token: ${GITHUB_TOKEN:}
13+
14+

0 commit comments

Comments
 (0)