2021-02-12 23:37:41 +01:00
|
|
|
package netlify
|
|
|
|
|
2021-02-19 03:32:07 +01:00
|
|
|
import (
|
|
|
|
"dagger.io/dagger"
|
|
|
|
"dagger.io/alpine"
|
2021-05-06 08:53:04 +02:00
|
|
|
"dagger.io/os"
|
2021-02-19 03:32:07 +01:00
|
|
|
)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
|
|
|
// A Netlify account
|
|
|
|
#Account: {
|
|
|
|
// Use this Netlify account name
|
|
|
|
// (also referred to as "team" in the Netlify docs)
|
2021-05-26 12:23:44 +02:00
|
|
|
name: string | *"" @dagger(input)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
|
|
|
// Netlify authentication token
|
2021-05-26 12:23:44 +02:00
|
|
|
token: dagger.#Secret @dagger(input)
|
2021-02-12 23:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// A Netlify site
|
|
|
|
#Site: {
|
|
|
|
// Netlify account this site is attached to
|
|
|
|
account: #Account
|
|
|
|
|
|
|
|
// Contents of the application to deploy
|
2021-05-26 12:23:44 +02:00
|
|
|
contents: dagger.#Artifact @dagger(input)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
|
|
|
// Deploy to this Netlify site
|
2021-05-26 12:23:44 +02:00
|
|
|
name: string @dagger(input)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
|
|
|
// Host the site at this address
|
2021-05-26 12:23:44 +02:00
|
|
|
customDomain?: string @dagger(input)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
|
|
|
// Create the Netlify site if it doesn't exist?
|
2021-05-26 12:23:44 +02:00
|
|
|
create: bool | *true @dagger(input)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
2021-03-19 01:37:54 +01:00
|
|
|
// Website url
|
2021-05-06 08:53:04 +02:00
|
|
|
url: {
|
|
|
|
os.#File & {
|
2021-05-26 12:28:24 +02:00
|
|
|
from: ctr
|
|
|
|
path: "/netlify/url"
|
|
|
|
}
|
2021-05-26 12:23:44 +02:00
|
|
|
}.read.data @dagger(output)
|
2021-03-19 01:37:54 +01:00
|
|
|
|
|
|
|
// Unique Deploy URL
|
2021-05-06 08:53:04 +02:00
|
|
|
deployUrl: {
|
|
|
|
os.#File & {
|
2021-05-26 12:28:24 +02:00
|
|
|
from: ctr
|
|
|
|
path: "/netlify/deployUrl"
|
|
|
|
}
|
2021-05-26 12:23:44 +02:00
|
|
|
}.read.data @dagger(output)
|
2021-03-19 01:37:54 +01:00
|
|
|
|
|
|
|
// Logs URL for this deployment
|
2021-05-06 08:53:04 +02:00
|
|
|
logsUrl: {
|
|
|
|
os.#File & {
|
2021-05-26 12:28:24 +02:00
|
|
|
from: ctr
|
|
|
|
path: "/netlify/logsUrl"
|
|
|
|
}
|
2021-05-26 12:23:44 +02:00
|
|
|
}.read.data @dagger(output)
|
2021-03-19 01:37:54 +01:00
|
|
|
|
2021-05-06 08:53:04 +02:00
|
|
|
ctr: os.#Container & {
|
|
|
|
image: alpine.#Image & {
|
|
|
|
package: {
|
|
|
|
bash: "=~5.1"
|
|
|
|
jq: "=~1.6"
|
2021-05-27 14:20:15 +02:00
|
|
|
curl: true
|
2021-05-06 08:53:04 +02:00
|
|
|
yarn: "=~1.22"
|
2021-03-19 01:37:54 +01:00
|
|
|
}
|
2021-05-06 08:53:04 +02:00
|
|
|
}
|
|
|
|
setup: [
|
|
|
|
"yarn global add netlify-cli@2.47.0",
|
|
|
|
]
|
|
|
|
// set in netlify.sh.cue
|
|
|
|
// FIXME: use embedding once cue supports it
|
|
|
|
command: _
|
|
|
|
env: {
|
|
|
|
NETLIFY_SITE_NAME: name
|
|
|
|
if (create) {
|
|
|
|
NETLIFY_SITE_CREATE: "1"
|
2021-03-19 01:37:54 +01:00
|
|
|
}
|
2021-05-06 08:53:04 +02:00
|
|
|
if customDomain != _|_ {
|
|
|
|
NETLIFY_DOMAIN: customDomain
|
|
|
|
}
|
|
|
|
NETLIFY_ACCOUNT: account.name
|
|
|
|
NETLIFY_AUTH_TOKEN: account.token
|
|
|
|
}
|
|
|
|
dir: "/src"
|
|
|
|
mount: "/src": from: contents
|
|
|
|
}
|
2021-04-08 03:01:32 +02:00
|
|
|
}
|