1- import { execFileSync , spawnSync } from 'node:child_process '
2- import { mkdir , readdir , unlink } from 'node:fs/promises '
3- import path from 'node:path '
1+ import path from 'path '
2+ import { execFileSync , spawnSync , type ExecFileSyncOptionsWithStringEncoding } from 'child_process '
3+ import { mkdir , readdir , unlink } from 'fs/promises '
44
55type Extractor = ( zipPath : string , targetDir : string ) => void
66
7+ const { BRANCH , WORKFLOW , DEST_DIR , REPOSITORY = 'curvefi/curve-frontend' } = process . env
8+
79/**
810 * Execute a command and return trimmed stdout.
911 */
10- const run = ( command : string , args : string [ ] , options ?: Parameters < typeof execFileSync > [ 2 ] ) : string =>
12+ const run = ( command : string , args : string [ ] , options ?: ExecFileSyncOptionsWithStringEncoding ) : string =>
1113 execFileSync ( command , args , {
1214 encoding : 'utf8' ,
1315 stdio : [ 'inherit' , 'pipe' , 'pipe' ] ,
@@ -46,6 +48,8 @@ const findLatestRunId = (branch: string, workflow: string): string =>
4648 run ( 'gh' , [
4749 'run' ,
4850 'list' ,
51+ '--repo' ,
52+ REPOSITORY ,
4953 '--branch' ,
5054 branch ,
5155 '--workflow' ,
@@ -62,7 +66,7 @@ const findLatestRunId = (branch: string, workflow: string): string =>
6266 * Download artifacts for the given run into dest.
6367 */
6468const downloadArtifacts = ( runId : string , dest : string ) => {
65- runStreaming ( 'gh' , [ 'run' , 'download' , runId , '--dir' , dest ] )
69+ runStreaming ( 'gh' , [ 'run' , 'download' , runId , '--repo' , REPOSITORY , '-- dir', dest ] )
6670}
6771
6872/**
@@ -100,7 +104,6 @@ async function downloadLatestArtifacts(): Promise<void> {
100104 const repoRoot = run ( 'git' , [ 'rev-parse' , '--show-toplevel' ] )
101105 process . chdir ( repoRoot )
102106
103- const { BRANCH , WORKFLOW , DEST_DIR } = process . env
104107 const branch = BRANCH ?. trim ( ) || run ( 'git' , [ 'rev-parse' , '--abbrev-ref' , 'HEAD' ] )
105108 const workflow = WORKFLOW ?. trim ( ) || 'ci.yaml'
106109 const runId = findLatestRunId ( branch , workflow )
0 commit comments