Skip to content

Commit b256d38

Browse files
committed
Fix deploy, refactor
1 parent 7c726fb commit b256d38

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

.dagger/src/index.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,26 @@ export class AtomicServer {
8484
@func()
8585
docsPublish(@argument() netlifyAuthToken: Secret): Promise<string> {
8686
const builtDocsHtml = this.docsFolder();
87+
return this.netlifyDeploy(builtDocsHtml, "atomic-docs", netlifyAuthToken);
88+
}
89+
90+
private netlifyDeploy(
91+
/** The directory to deploy */
92+
directory: Directory,
93+
siteName: string,
94+
netlifyAuthToken: Secret
95+
): Promise<string> {
8796
return dag
8897
.container()
8998
.from(NODE_IMAGE)
9099
.withExec(["npm", "install", "-g", "netlify-cli"])
100+
.withDirectory("/deploy", directory)
101+
.withWorkdir("/deploy")
91102
.withSecretVariable("NETLIFY_AUTH_TOKEN", netlifyAuthToken)
92-
.withDirectory("/html", builtDocsHtml)
93-
.withWorkdir("/html")
94103
.withExec([
95104
"sh",
96105
"-c",
97-
"netlify link --name atomic-docs --auth $NETLIFY_AUTH_TOKEN",
106+
`netlify link --name ${siteName} --auth $NETLIFY_AUTH_TOKEN`,
98107
])
99108
.withExec(["netlify", "deploy", "--dir", ".", "--prod"])
100109
.stdout();
@@ -308,17 +317,14 @@ export class AtomicServer {
308317
.withExec(["zip", "-r", "test.zip", "playwright-report"])
309318
.withExec(["unzip", "-o", "test.zip", "-d", "/artifact"]);
310319

311-
// Upload test results to Netlify
312-
return testResult
313-
.withExec([
314-
"netlify",
315-
"deploy",
316-
"--dir",
317-
"/artifact/app/playwright-report",
318-
"--prod",
319-
"--site",
320-
"atomic-tests",
321-
])
322-
.stdout();
320+
// Extract the test results directory and upload to Netlify
321+
const testReportDirectory = testResult.directory(
322+
"/artifact/app/playwright-report"
323+
);
324+
return this.netlifyDeploy(
325+
testReportDirectory,
326+
"atomic-tests",
327+
netlifyAuthToken
328+
);
323329
}
324330
}

0 commit comments

Comments
 (0)