2021-06-15 10:46:56 +02:00
|
|
|
// Netlify client operations
|
2021-02-12 23:37:41 +01:00
|
|
|
package netlify
|
|
|
|
|
2021-02-19 03:32:07 +01:00
|
|
|
import (
|
2021-06-23 16:31:42 +02:00
|
|
|
"alpha.dagger.io/dagger"
|
|
|
|
"alpha.dagger.io/alpine"
|
|
|
|
"alpha.dagger.io/os"
|
2021-02-19 03:32:07 +01:00
|
|
|
)
|
2021-02-12 23:37:41 +01:00
|
|
|
|
2021-06-15 10:46:56 +02:00
|
|
|
// Netlify account credentials
|
2021-02-12 23:37:41 +01:00
|
|
|
#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
|
|
|
}
|
|
|
|
|
2021-06-15 10:46:56 +02:00
|
|
|
// Netlify site
|
2021-02-12 23:37:41 +01:00
|
|
|
#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-06-09 20:37:05 +02:00
|
|
|
}.contents @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-06-09 20:37:05 +02:00
|
|
|
}.contents @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-06-09 20:37:05 +02:00
|
|
|
}.contents @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: [
|
2021-06-28 16:15:03 +02:00
|
|
|
"yarn global add netlify-cli@3.38.10",
|
2021-05-06 08:53:04 +02:00
|
|
|
]
|
|
|
|
// 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
|
|
|
|
}
|
2021-05-26 03:56:16 +02:00
|
|
|
NETLIFY_ACCOUNT: account.name
|
2021-05-06 08:53:04 +02:00
|
|
|
}
|
|
|
|
dir: "/src"
|
2021-06-23 12:46:56 +02:00
|
|
|
mount: "/src": from: contents
|
|
|
|
secret: "/run/secrets/token": account.token
|
2021-05-06 08:53:04 +02:00
|
|
|
}
|
2021-04-08 03:01:32 +02:00
|
|
|
}
|