docs: deploy using dagger
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
39527b761d
commit
c95b5d2bae
2
.dagger/env/docs/.gitignore
vendored
Normal file
2
.dagger/env/docs/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# dagger state
|
||||||
|
state/**
|
95
.dagger/env/docs/plan/main.cue
vendored
Normal file
95
.dagger/env/docs/plan/main.cue
vendored
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"dagger.io/dagger"
|
||||||
|
"dagger.io/os"
|
||||||
|
|
||||||
|
"dagger.io/js/yarn"
|
||||||
|
"dagger.io/git"
|
||||||
|
"dagger.io/docker"
|
||||||
|
|
||||||
|
"dagger.io/aws"
|
||||||
|
"dagger.io/aws/s3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// dagger repository
|
||||||
|
repository: dagger.#Artifact @dagger(input)
|
||||||
|
|
||||||
|
// docs version
|
||||||
|
version: string | *"devel" @dagger(input)
|
||||||
|
|
||||||
|
// if repository is checked out at a tag, use it as the version
|
||||||
|
tag: git.#CurrentBranch & {
|
||||||
|
"repository": repository
|
||||||
|
}
|
||||||
|
if (tag.name & =~"^v") != _|_ {
|
||||||
|
version: tag.name
|
||||||
|
}
|
||||||
|
|
||||||
|
// AWS credentials
|
||||||
|
awsConfig: aws.#Config @dagger(input)
|
||||||
|
|
||||||
|
// Lint the markdowns
|
||||||
|
lint: os.#Container & {
|
||||||
|
image: docker.#Pull & {
|
||||||
|
from: "tmknom/markdownlint:0.23.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
command: "markdownlint ./docs"
|
||||||
|
dir: "/src"
|
||||||
|
mount: "/src": from: repository
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the docs website
|
||||||
|
docs: yarn.#Package & {
|
||||||
|
source: repository
|
||||||
|
cwd: "./tools/gendocs"
|
||||||
|
buildDir: "./tools/gendocs/public"
|
||||||
|
args: ["--prefix-paths"]
|
||||||
|
env: VERSION: version
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload to S3
|
||||||
|
website: s3.#Sync & {
|
||||||
|
config: awsConfig
|
||||||
|
source: docs.build
|
||||||
|
delete: true
|
||||||
|
target: "s3://docs.dagger.io/\(version)/"
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate and upload a `tags.json` file for the navbar version selector
|
||||||
|
tags: git.#Tags & {
|
||||||
|
"repository": repository
|
||||||
|
}
|
||||||
|
versions: [ for name in tags.tags {tag: name}, {
|
||||||
|
tag: "devel"
|
||||||
|
}]
|
||||||
|
|
||||||
|
versionsObject: s3.#Put & {
|
||||||
|
config: awsConfig
|
||||||
|
sourceInline: json.Marshal(versions)
|
||||||
|
contentType: "application/json"
|
||||||
|
target: "s3://docs.dagger.io/tags.json"
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we're building a release, redirect the docs website to this page
|
||||||
|
if version != "devel" {
|
||||||
|
redirect: s3.#Put & {
|
||||||
|
config: awsConfig
|
||||||
|
sourceInline: #"""
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="0; url=/\#(version)">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Nothing to see here; <a href="/\#(version)">see the latest version of the docs</a>.
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""#
|
||||||
|
contentType: "text/html"
|
||||||
|
target: "s3://docs.dagger.io/index.html"
|
||||||
|
}
|
||||||
|
}
|
35
.dagger/env/docs/values.yaml
vendored
Normal file
35
.dagger/env/docs/values.yaml
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
name: docs
|
||||||
|
inputs:
|
||||||
|
awsConfig.accessKey:
|
||||||
|
secret: ENC[AES256_GCM,data:/KR+mkBb51etyZqiQnl4kxIl4vw=,iv:lFBuaqK9MVr5fYGMM8bN/XyZ9/oUInDWvzhYuK8Yj20=,tag:sHwcSTJ1lKzIDRYzr4Z/yg==,type:str]
|
||||||
|
awsConfig.region:
|
||||||
|
text: us-east-1
|
||||||
|
awsConfig.secretKey:
|
||||||
|
secret: ENC[AES256_GCM,data:0bHcnNwbKR2F+PKB/Xzs06zsvJHENPZHEcx9SUN3Sn2/fzf0fA2G2w==,iv:A306R2ldjigteL6c0jkvOxZbHtxhlobP2FuPknuf+N4=,tag:CvDqdrej34Kbh8Y7zG5O8Q==,type:str]
|
||||||
|
repository:
|
||||||
|
dir:
|
||||||
|
path: .
|
||||||
|
exclude:
|
||||||
|
- '**/node_modules'
|
||||||
|
- cmd/dagger/dagger
|
||||||
|
- cmd/dagger/dagger-debug
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBaZVVuYThsYk9YcWhYb0g4
|
||||||
|
TDhZQ21YN0FCRExKV2tqbVVUNTg5MWRUVUJzCndjc28yVUZEK3ZoQzVDQkk4emZQ
|
||||||
|
WGx2bUxSZlBENXlibzQ1MVkvc2I2MVkKLS0tIFJKS0ZENFhuVmdUM2h1a2xrK01a
|
||||||
|
ejRKQXNFZzBTbUxpc05acnkxQ2U2UkEKX1byNj64xOiRGAJ9lwh55d/mlasI3H6H
|
||||||
|
b+o3HbXSbV0G0UwQxEOisntR6o27ry/l12ai/sOQ4f9MXm6FRw2XTg==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2021-05-29T02:37:17Z"
|
||||||
|
mac: ENC[AES256_GCM,data:mXlkcR6U0sQwXdk4mYMKmA6/tcZWVtQt76RVfYOj3uE89XgIUQhk5qts/fp8DMpOB90KZtUJB2Im2+ppqdhtKQO2xcp0Cj6WN1omYRdGbSAMBMPtIbbAdzMcZwvCScRvfDn1ecCSeHikTpDlvUImmoOJLH4ItvLq7JK3oUgPvUs=,iv:ckI70eAguY4p8eTI2W5Iws1zYaqkZuHcNWwjGBjbVYk=,tag:/hoRjWxK/5oxbmia4TgcKA==,type:str]
|
||||||
|
pgp: []
|
||||||
|
encrypted_suffix: secret
|
||||||
|
version: 3.7.1
|
@ -213,6 +213,8 @@ func (p *Pipeline) doOp(ctx context.Context, op *compiler.Value, st llb.State) (
|
|||||||
return p.Local(ctx, op, st)
|
return p.Local(ctx, op, st)
|
||||||
case "load":
|
case "load":
|
||||||
return p.Load(ctx, op, st)
|
return p.Load(ctx, op, st)
|
||||||
|
case "workdir":
|
||||||
|
return p.Workdir(ctx, op, st)
|
||||||
case "subdir":
|
case "subdir":
|
||||||
return p.Subdir(ctx, op, st)
|
return p.Subdir(ctx, op, st)
|
||||||
case "docker-build":
|
case "docker-build":
|
||||||
@ -232,6 +234,14 @@ func (p *Pipeline) vertexNamef(format string, a ...interface{}) string {
|
|||||||
return prefix + " " + name
|
return prefix + " " + name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Pipeline) Workdir(ctx context.Context, op *compiler.Value, st llb.State) (llb.State, error) {
|
||||||
|
path, err := op.Lookup("path").String()
|
||||||
|
if err != nil {
|
||||||
|
return st, err
|
||||||
|
}
|
||||||
|
return st.Dir(path), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Pipeline) Subdir(ctx context.Context, op *compiler.Value, st llb.State) (llb.State, error) {
|
func (p *Pipeline) Subdir(ctx context.Context, op *compiler.Value, st llb.State) (llb.State, error) {
|
||||||
// FIXME: this could be more optimized by carrying subdir path as metadata,
|
// FIXME: this could be more optimized by carrying subdir path as metadata,
|
||||||
// and using it in copy, load or mount.
|
// and using it in copy, load or mount.
|
||||||
|
@ -40,6 +40,11 @@ package op
|
|||||||
dir: string
|
dir: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Workdir: {
|
||||||
|
do: "workdir"
|
||||||
|
path: string
|
||||||
|
}
|
||||||
|
|
||||||
#Exec: {
|
#Exec: {
|
||||||
do: "exec"
|
do: "exec"
|
||||||
args: [...string]
|
args: [...string]
|
||||||
|
@ -12,6 +12,7 @@ package op
|
|||||||
#Copy |
|
#Copy |
|
||||||
#Load |
|
#Load |
|
||||||
#Subdir |
|
#Subdir |
|
||||||
|
#Workdir |
|
||||||
#WriteFile |
|
#WriteFile |
|
||||||
#Mkdir |
|
#Mkdir |
|
||||||
#DockerBuild) & {do: string}
|
#DockerBuild) & {do: string}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"dagger.io/dagger"
|
||||||
"dagger.io/dagger/op"
|
"dagger.io/dagger/op"
|
||||||
|
"dagger.io/alpine"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A git repository
|
// A git repository
|
||||||
@ -23,3 +25,82 @@ import (
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the name of the current checked out branch or tag
|
||||||
|
#CurrentBranch: {
|
||||||
|
repository: dagger.#Artifact @dagger(input)
|
||||||
|
name: {
|
||||||
|
string
|
||||||
|
@dagger(output)
|
||||||
|
|
||||||
|
#up: [
|
||||||
|
op.#Load & {
|
||||||
|
from: alpine.#Image & {
|
||||||
|
package: bash: "=~5.1"
|
||||||
|
package: git: "=~2.30"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Exec & {
|
||||||
|
mount: "/repository": from: repository
|
||||||
|
dir: "/repository"
|
||||||
|
args: [
|
||||||
|
"/bin/bash",
|
||||||
|
"--noprofile",
|
||||||
|
"--norc",
|
||||||
|
"-eo",
|
||||||
|
"pipefail",
|
||||||
|
"-c",
|
||||||
|
#"""
|
||||||
|
printf "$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" > /name.txt
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Export & {
|
||||||
|
source: "/name.txt"
|
||||||
|
format: "string"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List tags of a repository
|
||||||
|
#Tags: {
|
||||||
|
repository: dagger.#Artifact @dagger(input)
|
||||||
|
tags: {
|
||||||
|
[...string]
|
||||||
|
@dagger(output)
|
||||||
|
|
||||||
|
#up: [
|
||||||
|
op.#Load & {
|
||||||
|
from: alpine.#Image & {
|
||||||
|
package: bash: "=~5.1"
|
||||||
|
package: jq: "=~1.6"
|
||||||
|
package: git: "=~2.30"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Exec & {
|
||||||
|
mount: "/repository": from: repository
|
||||||
|
dir: "/repository"
|
||||||
|
args: [
|
||||||
|
"/bin/bash",
|
||||||
|
"--noprofile",
|
||||||
|
"--norc",
|
||||||
|
"-eo",
|
||||||
|
"pipefail",
|
||||||
|
"-c",
|
||||||
|
#"""
|
||||||
|
git tag -l | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' > /tags.json
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Export & {
|
||||||
|
source: "/tags.json"
|
||||||
|
format: "json"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user