@@ -4,6 +4,7 @@ import os from "os"
44import paths from "path"
55import git from "simple-git"
66import { filters } from "../../../app/metrics/utils.mjs"
7+ import core from "@actions/core"
78
89/**Analyzer */
910export class Analyzer {
@@ -86,21 +87,27 @@ export class Analyzer {
8687 /**Clone a repository */
8788 async clone ( repository ) {
8889 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 } `
9097 try {
91- this . debug ( `cloning ${ url } to ${ path } ` )
98+ this . debug ( `cloning https://github.com/ ${ repo } to ${ path } ` )
9299 await fs . rm ( path , { recursive : true , force : true } )
93100 await fs . mkdir ( path , { recursive : true } )
94101 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 } ` )
96103 if ( branch ) {
97104 this . debug ( `switching to branch ${ branch } for ${ repo } ` )
98105 await git ( path ) . branch ( branch )
99106 }
100107 return true
101108 }
102109 catch ( error ) {
103- this . debug ( `failed to clone ${ url } (${ error } )` )
110+ this . debug ( `failed to clone https://github.com/ ${ repo } (${ error } )` )
104111 this . clean ( path )
105112 return false
106113 }
@@ -176,4 +183,4 @@ export class Analyzer {
176183 debug ( message ) {
177184 return console . debug ( `metrics/compute/${ this . login } /plugins > languages > ${ this . constructor . name . replace ( / ( [ a - z ] ) ( [ A - Z ] ) / , ( _ , a , b ) => `${ a } ${ b . toLocaleLowerCase ( ) } ` ) . toLocaleLowerCase ( ) } > ${ message } ` )
178185 }
179- }
186+ }
0 commit comments