@@ -98,7 +98,7 @@ async function main() {
9898 // Get the workflow run for this PR (using sanitized branch name)
9999 const runs = JSON . parse (
100100 execSync (
101- `gh api repos/HarperDB/documentation/actions/runs --paginate -X GET -f branch=${ sanitizedBranch } --jq '.workflow_runs | map(select(.conclusion == "success" and .name == "Deploy Docusaurus to GitHub Pages ")) | sort_by(.created_at) | reverse | .[0]'` ,
101+ `gh api repos/HarperDB/documentation/actions/runs --paginate -X GET -f branch=${ sanitizedBranch } --jq '.workflow_runs | map(select(.conclusion == "success" and .name == "Deploy PR Preview ")) | sort_by(.created_at) | reverse | .[0]'` ,
102102 { encoding : 'utf-8' }
103103 )
104104 ) ;
@@ -126,10 +126,11 @@ async function main() {
126126 } )
127127 ) ;
128128
129- const artifact = artifacts . find ( ( a ) => a . name === 'github-pages' ) ;
129+ const artifactName = `pr-${ PR_NUMBER } -build` ;
130+ const artifact = artifacts . find ( ( a ) => a . name === artifactName ) ;
130131
131132 if ( ! artifact ) {
132- console . error ( `❌ No 'github-pages ' artifact found for this PR` ) ;
133+ console . error ( `❌ No '${ artifactName } ' artifact found for this PR` ) ;
133134 process . exit ( 1 ) ;
134135 }
135136
@@ -170,28 +171,19 @@ async function main() {
170171 throw new Error ( 'Downloaded artifact file not found' ) ;
171172 }
172173
173- // Extract the artifact (it's a tar.gz inside a zip )
174+ // Extract the artifact (it's a direct zip of the build directory )
174175 console . log ( '📂 Extracting artifact...' ) ;
175- execSync ( `unzip -q "${ artifactZip } " -d "${ PR_DIR } "` , { stdio : 'inherit' } ) ;
176-
177- // The github-pages artifact contains a tar.gz file
178- const tarFile = join ( PR_DIR , 'artifact.tar' ) ;
179- if ( existsSync ( tarFile ) ) {
180- mkdirSync ( BUILD_DIR , { recursive : true } ) ;
181- execSync ( `tar -xzf "${ tarFile } " -C "${ BUILD_DIR } "` , { stdio : 'inherit' } ) ;
182- } else {
183- throw new Error ( 'Expected artifact.tar not found in artifact' ) ;
184- }
176+ mkdirSync ( BUILD_DIR , { recursive : true } ) ;
177+ execSync ( `unzip -q "${ artifactZip } " -d "${ BUILD_DIR } "` , { stdio : 'inherit' } ) ;
185178
186179 // Verify extracted files are within expected directory
187180 const resolvedBuildDir = join ( BUILD_DIR ) ;
188181 if ( ! resolvedBuildDir . startsWith ( PREVIEW_DIR ) ) {
189182 throw new Error ( 'Security violation: extracted files outside preview directory' ) ;
190183 }
191184
192- // Clean up compressed files
185+ // Clean up zip file
193186 rmSync ( artifactZip , { force : true } ) ;
194- rmSync ( tarFile , { force : true } ) ;
195187
196188 console . log ( '\n✅ Preview ready!\n' ) ;
197189 console . log ( `📁 Build location: ${ BUILD_DIR } ` ) ;
0 commit comments