2020-07-21 19:34:57 +02:00
|
|
|
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",
|
2020-07-21 19:34:57 +02:00
|
|
|
# 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" ] } },
|
2020-07-21 19:34:57 +02:00
|
|
|
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-07-21 19:34:57 +02:00
|
|
|
},
|
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
|
|
|
],
|
|
|
|
},
|
2020-07-21 19:34:57 +02:00
|
|
|
{
|
2021-08-08 16:24:45 +02:00
|
|
|
# If dev, include drafts and future articles, change base URL
|
2020-07-21 19:34:57 +02:00
|
|
|
name: "build",
|
|
|
|
commands: [
|
2021-08-08 16:24:45 +02:00
|
|
|
"nix develop -c make " + if isDev then "build-dev" else "build-prod",
|
2020-07-21 19:34:57 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "deploy",
|
2021-08-08 16:24:45 +02:00
|
|
|
commands: [
|
|
|
|
"nix run github:ambroisie/nix-config#drone-scp",
|
|
|
|
],
|
|
|
|
environment: {
|
|
|
|
SCP_SOURCE: "public/*",
|
2021-08-15 10:54:03 +02:00
|
|
|
TAR_STRIP_COMPONENTS: 1, # Remove 'public/' suffix from file paths
|
2021-08-08 16:24:45 +02:00
|
|
|
SCP_RM: true, # Remove previous files from target directory
|
|
|
|
SCP_HOST: { from_secret: "ssh_host" },
|
|
|
|
SCP_TARGET: { from_secret: "ssh_target" + if isDev then "_dev" else "" },
|
|
|
|
SCP_USERNAME: { from_secret: "ssh_user" },
|
|
|
|
SCP_KEY: { from_secret: "ssh_key" },
|
|
|
|
SCP_PORT: { from_secret: "ssh_port" },
|
2020-07-21 19:34:57 +02:00
|
|
|
},
|
|
|
|
},
|
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
|
|
|
},
|
2020-07-21 19:34:57 +02:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
Pipeline(false),
|
|
|
|
Pipeline(true),
|
|
|
|
]
|