@@ -10,8 +10,7 @@ if (!outputFilePath) {
1010 process . exit ( 1 ) ;
1111}
1212
13- const owner = 'redhat-developer' ;
14- const repo = 'rhdh' ;
13+ const repository = process . env . GITHUB_REPOSITORY || 'redhat-developer/rhdh' ;
1514
1615// old branches
1716const skipBranches = [
@@ -47,8 +46,8 @@ const backendPackages = [
4746
4847// List all branches in the repository
4948// uses fetch and no github library to avoid depencies on extra libraries
50- async function listBranchNames ( owner , repo , page = 1 , collected = [ ] ) {
51- const url = `https://api.github.com/repos/${ owner } / ${ repo } /branches?page=${ page } ` ;
49+ async function listBranchNames ( repository , page = 1 , collected = [ ] ) {
50+ const url = `https://api.github.com/repos/${ repository } /branches?page=${ page } ` ;
5251
5352 try {
5453 const response = await fetch ( url , {
@@ -59,7 +58,7 @@ async function listBranchNames(owner, repo, page = 1, collected = []) {
5958
6059 if ( ! response . ok ) {
6160 if ( response . status === 404 ) {
62- console . log ( `Repository ${ owner } / ${ repo } not found.` ) ;
61+ console . log ( `Repository ${ repository } not found.` ) ;
6362 } else {
6463 console . error ( `Error listing branches:` , response . statusText ) ;
6564 }
@@ -74,7 +73,7 @@ async function listBranchNames(owner, repo, page = 1, collected = []) {
7473 const hasNext = links && links . includes ( 'rel="next"' ) ;
7574
7675 if ( hasNext ) {
77- return listBranchNames ( owner , repo , page + 1 , allNames ) ;
76+ return listBranchNames ( repository , page + 1 , allNames ) ;
7877 } else {
7978 return allNames ;
8079 }
@@ -86,8 +85,8 @@ async function listBranchNames(owner, repo, page = 1, collected = []) {
8685}
8786
8887// return the content of the file
89- async function getFileFromGithub ( owner , repo , branch , filePath ) {
90- const url = `https://raw.githubusercontent.com/${ owner } / ${ repo } /${ branch } /${ filePath } ` ;
88+ async function getFileFromGithub ( repository , branch , filePath ) {
89+ const url = `https://raw.githubusercontent.com/${ repository } /${ branch } /${ filePath } ` ;
9190 try {
9291 const response = await fetch ( url , {
9392 headers : {
@@ -145,7 +144,7 @@ async function writeToFile(filePath, content) {
145144
146145async function main ( ) {
147146
148- const allBranches = await listBranchNames ( owner , repo ) ;
147+ const allBranches = await listBranchNames ( repository ) ;
149148
150149 // only release branches and not in skipBranches
151150 const relaseBranches = allBranches
@@ -179,7 +178,7 @@ async function main() {
179178 }
180179 console . log ( `Release: ${ release } ` )
181180
182- const backstageJson = await getFileFromGithub ( owner , repo , branch , backstageJsonPath ) ;
181+ const backstageJson = await getFileFromGithub ( repository , branch , backstageJsonPath ) ;
183182 const backstageVersion = JSON . parse ( backstageJson ) . version
184183
185184 if ( ! backstageVersion ) {
@@ -188,15 +187,15 @@ async function main() {
188187
189188 const minorBackstageVersion = backstageVersion . split ( '.' ) . slice ( 0 , 2 ) . join ( '.' )
190189
191- const frontendPackageJson = await getFileFromGithub ( owner , repo , branch , frontendPackageJsonPath ) ;
192- const backendPackageJson = await getFileFromGithub ( owner , repo , branch , backendPackageJsonPath ) ;
190+ const frontendPackageJson = await getFileFromGithub ( repository , branch , frontendPackageJsonPath ) ;
191+ const backendPackageJson = await getFileFromGithub ( repository , branch , backendPackageJsonPath ) ;
193192
194193 const frontendTable = await generateTable ( JSON . parse ( frontendPackageJson ) , frontendPackages )
195194 const backendTable = await generateTable ( JSON . parse ( backendPackageJson ) , backendPackages )
196195
197196 const preRelaseInfo = `(pre-release, versions can change for final release)`
198197
199- const createAppPackageJson = await getFileFromGithub ( "backstage" , " backstage", `v${ backstageVersion } ` , 'packages/create-app/package.json' ) ;
198+ const createAppPackageJson = await getFileFromGithub ( "backstage/ backstage" , `v${ backstageVersion } ` , 'packages/create-app/package.json' ) ;
200199 const createAppVersion = JSON . parse ( createAppPackageJson ) . version
201200
202201 if ( ! createAppVersion ) {
0 commit comments