ci: use Jsonnet for YAML configuration generation
Because the two kinds of pipelines were very similar, I used Jsonnet to factorise the definitions. This means I have to switch the configuration file in my settings, and enable Jsonnet files.
This commit is contained in:
parent
9e410507d1
commit
0136c99742
2 changed files with 45 additions and 76 deletions
45
.drone.jsonnet
Normal file
45
.drone.jsonnet
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
local Pipeline(isDev) = {
|
||||
kind: "pipeline",
|
||||
name: if isDev then "deploy-dev" else "deploy-prod",
|
||||
# Dev ignores "master", prod only triggers on "master"
|
||||
trigger: { branch: { [if isDev then "exclude" else "include"]: [ "master" ] } },
|
||||
# We want to clone the submodules, which isn't done by default
|
||||
clone: { disable: true },
|
||||
steps: [
|
||||
{
|
||||
name: "clone",
|
||||
image: "plugins/git",
|
||||
recursive: true,
|
||||
},
|
||||
{
|
||||
name: "build",
|
||||
image: "klakegg/hugo",
|
||||
commands: [
|
||||
"hugo version",
|
||||
# If dev, include drafts and future articles, change base URL
|
||||
"hugo --minify" + if isDev then " -D -F -b https://dev.belanyi.fr" else "",
|
||||
],
|
||||
[if !isDev then "environment"]: { HUGO_ENV: "production" }
|
||||
},
|
||||
{
|
||||
name: "deploy",
|
||||
image: "appleboy/drone-scp",
|
||||
settings: {
|
||||
source: "public/*",
|
||||
strip_components: 1, # Remove 'public/' suffix from file paths
|
||||
rm: true, # Remove previous files from target directory
|
||||
host: { from_secret: "ssh_host" },
|
||||
target: { from_secret: "ssh_target" + if isDev then "_dev" else "" },
|
||||
username: { from_secret: "ssh_user" },
|
||||
key: { from_secret: "ssh_key" },
|
||||
port: { from_secret: "ssh_port" },
|
||||
},
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
[
|
||||
Pipeline(false),
|
||||
Pipeline(true),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue