stdlib: netlify: export the deployUrl and logsUrl

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2021-03-18 17:37:54 -07:00
parent 5438e4177c
commit fbdfe27103
2 changed files with 57 additions and 45 deletions

View File

@ -33,52 +33,56 @@ import (
// Create the Netlify site if it doesn't exist? // Create the Netlify site if it doesn't exist?
create: bool | *true create: bool | *true
// Deployment url // Website url
url: { url: string
string
#compute: [ // Unique Deploy URL
llb.#Load & { deployUrl: string
from: alpine.#Image & {
package: bash: "=~5.1" // Logs URL for this deployment
package: jq: "=~1.6" logsUrl: string
package: curl: "=~7.74"
package: yarn: "=~1.22" #compute: [
llb.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
package: jq: "=~1.6"
package: curl: "=~7.74"
package: yarn: "=~1.22"
}
},
llb.#Exec & {
args: ["yarn", "global", "add", "netlify-cli@2.47.0"]
},
llb.#Exec & {
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"-c",
code,
]
env: {
NETLIFY_SITE_NAME: name
if (create) {
NETLIFY_SITE_CREATE: "1"
} }
}, if customDomain != _|_ {
llb.#Exec & { NETLIFY_DOMAIN: customDomain
args: ["yarn", "global", "add", "netlify-cli@2.47.0"]
},
llb.#Exec & {
args: [
"/bin/bash",
"--noprofile",
"--norc",
"-eo",
"pipefail",
"-c",
code,
]
env: {
NETLIFY_SITE_NAME: name
if (create) {
NETLIFY_SITE_CREATE: "1"
}
if customDomain != _|_ {
NETLIFY_DOMAIN: customDomain
}
NETLIFY_ACCOUNT: account.name
NETLIFY_AUTH_TOKEN: account.token
} }
dir: "/src" NETLIFY_ACCOUNT: account.name
mount: "/src": from: contents NETLIFY_AUTH_TOKEN: account.token
}, }
llb.#Export & { dir: "/src"
source: "/url" mount: "/src": from: contents
format: "string" },
}, llb.#Export & {
] source: "/output.json"
} format: "json"
},
]
} }
// FIXME: this should be outside // FIXME: this should be outside
@ -119,5 +123,13 @@ let code = #"""
--prod \ --prod \
| tee /tmp/stdout | tee /tmp/stdout
</tmp/stdout sed -n -e 's/^Website URL:.*\(https:\/\/.*\)$/\1/p' | tr -d '\n' > /url url=$(</tmp/stdout sed -n -e 's/^Website URL:.*\(https:\/\/.*\)$/\1/p' | tr -d '\n')
deployUrl=$(</tmp/stdout sed -n -e 's/^Unique Deploy URL:.*\(https:\/\/.*\)$/\1/p' | tr -d '\n')
logsUrl=$(</tmp/stdout sed -n -e 's/^Logs:.*\(https:\/\/.*\)$/\1/p' | tr -d '\n')
jq -n \
--arg url "$url" \
--arg deployUrl "$deployUrl" \
--arg logsUrl "$logsUrl" \
'{url: $url, deployUrl: $deployUrl, logsUrl: $logsUrl}' > /output.json
"""# """#

View File

@ -52,7 +52,7 @@ TestNetlify: {
"pipefail", "pipefail",
"-c", "-c",
#""" #"""
test "$(curl \#(deploy.url))" = "\#(random)" test "$(curl \#(deploy.deployUrl))" = "\#(random)"
"""#, """#,
] ]
}, },