File tree Expand file tree Collapse file tree 5 files changed +30
-21
lines changed
Expand file tree Collapse file tree 5 files changed +30
-21
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ podman push ghcr.io/your-username/cra-github:latest
4646
4747Update the workflow file to use your image: ` docker://ghcr.io/your-username/cra-github:latest `
4848
49+ Example for the current ` review.yml ` :
50+
51+ ``` bash
52+ podman build -t ghcr.io/sayansisodiya/cra-github:latest . && podman push ghcr.io/sayansisodiya/cra-github:latest
53+ ```
54+
4955### Local Development
5056
51571 . ** Clone and Install**
Original file line number Diff line number Diff line change @@ -28,25 +28,26 @@ export class GitHubClient {
2828 this . baseUrl = ( githubConfig . base_url ?? 'https://api.github.com' ) . replace ( / \/ $ / , '' ) ;
2929 }
3030
31- static forInstallation ( config : Config , installationId : number ) : GitHubClient {
32- return new GitHubClient ( config , installationId ) ;
33- }
34-
35- static fromEnv ( config : Config ) : GitHubClient {
31+ static create ( config : Config , options ?: { installationId ?: number ; token ?: string } ) : GitHubClient {
32+ if ( options ?. token ) {
33+ const configWithToken = {
34+ ...config ,
35+ github : {
36+ ...config . github ,
37+ token : options . token
38+ }
39+ } ;
40+ return new GitHubClient ( configWithToken ) ;
41+ }
42+
43+ if ( options ?. installationId ) {
44+ return new GitHubClient ( config , options . installationId ) ;
45+ }
46+
47+ // Auto-detect from environment (GITHUB_INSTALLATION_ID)
3648 return new GitHubClient ( config ) ;
3749 }
3850
39- static forToken ( config : Config , token : string ) : GitHubClient {
40- const configWithToken = {
41- ...config ,
42- github : {
43- ...config . github ,
44- token
45- }
46- } ;
47- return new GitHubClient ( configWithToken ) ;
48- }
49-
5051 private async getAuthHeaders ( ) : Promise < Record < string , string > > {
5152 const headers = {
5253 'Accept' : 'application/vnd.github.v3+json' ,
Original file line number Diff line number Diff line change @@ -12,9 +12,11 @@ export async function processReview(
1212
1313 // Use GITHUB_TOKEN from Actions environment if available, otherwise use GitHub App
1414 const githubToken = process . env . GITHUB_TOKEN ;
15- const githubClient = githubToken
16- ? GitHubClient . forToken ( config , githubToken )
17- : GitHubClient . forInstallation ( config , installationId ) ;
15+ const githubClient = GitHubClient . create ( config ,
16+ githubToken
17+ ? { token : githubToken }
18+ : { installationId }
19+ ) ;
1820
1921 try {
2022 // Extract PR information
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ async function handleCheckRunActionEvent(payload: any) {
140140 // We need to fetch the full PR data since we don't have it in the check run payload
141141 const config = getConfig ( ) ;
142142 const { GitHubClient } = await import ( '../github/client.js' ) ;
143- const githubClient = GitHubClient . forInstallation ( config , installationId ) ;
143+ const githubClient = GitHubClient . create ( config , { installationId } ) ;
144144
145145 console . log ( `Fetching PR ${ prNumber } details for re-review job ${ jobId } ` ) ;
146146 const prData = await githubClient . getPRInfo ( repository . owner . login , repository . name , prNumber ) ;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ if (action === 'execute') {
3838 const { getConfig } = await distImport ( 'config.js' ) ;
3939
4040 const config = getConfig ( ) ;
41- const gh = GitHubClient . fromEnv ( config ) ;
41+ const gh = GitHubClient . create ( config ) ;
4242
4343 const comments = await gh . getPRComments ( owner , repo , prNumber ) ;
4444
You can’t perform that action at this time.
0 commit comments