@@ -4,6 +4,7 @@ import os from "os"
4
4
import paths from "path"
5
5
import git from "simple-git"
6
6
import { filters } from "../../../app/metrics/utils.mjs"
7
+ import core from "@actions/core"
7
8
8
9
/**Analyzer */
9
10
export class Analyzer {
@@ -86,21 +87,27 @@ export class Analyzer {
86
87
/**Clone a repository */
87
88
async clone ( repository ) {
88
89
const { repo, branch, path} = this . parse ( repository )
89
- let url = / ^ h t t p s ? : \/ \/ / . test ( repo ) ? repo : `https://github.com/${ repo } `
90
+ let token
91
+
92
+ if ( process . env . GITHUB_ACTIONS ) {
93
+ token = core . getInput ( "token" )
94
+ }
95
+
96
+ let url = / ^ h t t p s ? : \/ \/ / . test ( repo ) ? repo : `https://${ token } @github.com/${ repo } `
90
97
try {
91
- this . debug ( `cloning ${ url } to ${ path } ` )
98
+ this . debug ( `cloning https://github.com/ ${ repo } to ${ path } ` )
92
99
await fs . rm ( path , { recursive : true , force : true } )
93
100
await fs . mkdir ( path , { recursive : true } )
94
101
await git ( path ) . clone ( url , "." , [ "--single-branch" ] ) . status ( )
95
- this . debug ( `cloned ${ url } to ${ path } ` )
102
+ this . debug ( `cloned https://github.com/ ${ repo } to ${ path } ` )
96
103
if ( branch ) {
97
104
this . debug ( `switching to branch ${ branch } for ${ repo } ` )
98
105
await git ( path ) . branch ( branch )
99
106
}
100
107
return true
101
108
}
102
109
catch ( error ) {
103
- this . debug ( `failed to clone ${ url } (${ error } )` )
110
+ this . debug ( `failed to clone https://github.com/ ${ repo } (${ error } )` )
104
111
this . clean ( path )
105
112
return false
106
113
}
@@ -176,4 +183,4 @@ export class Analyzer {
176
183
debug ( message ) {
177
184
return console . debug ( `metrics/compute/${ this . login } /plugins > languages > ${ this . constructor . name . replace ( / ( [ a - z ] ) ( [ A - Z ] ) / , ( _ , a , b ) => `${ a } ${ b . toLocaleLowerCase ( ) } ` ) . toLocaleLowerCase ( ) } > ${ message } ` )
178
185
}
179
- }
186
+ }
0 commit comments