blog/.drone.jsonnet

65 lines
1.8 KiB
Plaintext
Raw Normal View History

local Pipeline(isDev) = {
kind: "pipeline",
2021-08-08 16:24:45 +02:00
type: "exec",
name: if isDev then "Deploy to dev" else "Deploy to prod",
# Dev ignores "master", prod only triggers on "master"
2020-10-23 17:23:54 +02:00
trigger: { branch: { [if isDev then "exclude" else "include"]: [ "main" ] } },
steps: [
{
2021-08-08 16:24:45 +02:00
# We want to clone the submodules, which isn't done by default
name: "submodules",
commands: [
"git submodule update --recursive --init",
]
},
2020-08-27 17:55:47 +02:00
{
2021-08-08 16:24:45 +02:00
# Include pre-commit checks, which include markdownlint
name: "check",
2020-08-27 17:55:47 +02:00
commands: [
2021-08-08 16:24:45 +02:00
"nix flake check",
2020-08-27 17:55:47 +02:00
],
},
{
2021-08-08 16:24:45 +02:00
# If dev, include drafts and future articles, change base URL
name: "build",
commands: [
2021-08-08 16:24:45 +02:00
"nix develop -c make " + if isDev then "build-dev" else "build-prod",
],
},
{
name: "deploy",
2021-08-08 16:24:45 +02:00
commands: [
2022-06-20 14:46:03 +02:00
"nix run github:ambroisie/nix-config#drone-rsync",
2021-08-08 16:24:45 +02:00
],
environment: {
2022-06-20 14:46:03 +02:00
# Trailing slash to synchronize the folder's *content* to the target
SYNC_SOURCE: "public/",
SYNC_HOST: { from_secret: "ssh_host" },
SYNC_TARGET: { from_secret: "ssh_target" + if isDev then "_dev" else "" },
SYNC_USERNAME: { from_secret: "ssh_user" },
SYNC_KEY: { from_secret: "ssh_key" },
SYNC_PORT: { from_secret: "ssh_port" },
},
},
2020-10-14 18:24:26 +02:00
{
name: "notify",
2021-08-08 16:24:45 +02:00
commands: [
"nix run github:ambroisie/matrix-notifier",
],
environment: {
ADDRESS: { from_secret: "matrix_homeserver" },
ROOM: { from_secret: "matrix_roomid" },
USER: { from_secret: "matrix_username" },
PASS: { from_secret: "matrix_password" },
2020-10-14 18:24:26 +02:00
},
2021-08-08 16:24:45 +02:00
when: { status: [ "failure", "success", ] },
2020-10-14 18:24:26 +02:00
},
]
};
[
Pipeline(false),
Pipeline(true),
]