Compare commits

...

11 commits

Author SHA1 Message Date
Bruno BELANYI 70a023df7a fixup! fixup! build: makefile: add deploy step
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:14:08 +02:00
Bruno BELANYI 324c0cc77d fixup! fixup! build: makefile: add deploy step 2021-08-08 17:14:08 +02:00
Bruno BELANYI 0cee06c573 fixup! 445b879afa 2021-08-08 17:13:04 +02:00
Bruno BELANYI 0986c64a80 fixup! build: makefile: add deploy step
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 16:58:18 +02:00
Bruno BELANYI 1a2dd074cb fixup! ci: use exec runner 2021-08-08 16:58:15 +02:00
Bruno BELANYI ff389ba1fa nix: add rsync to dev shell
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 16:45:53 +02:00
Bruno BELANYI cd808f311a nix: add openssh to dev shell
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 16:43:33 +02:00
Bruno BELANYI 445b879afa fixup! ci: use exec runner
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 16:41:13 +02:00
Bruno BELANYI 81c0fc89f3 build: makefile: change title on dev deployment 2021-08-08 16:37:32 +02:00
Bruno BELANYI 7295265a3e ci: use exec runner
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 16:24:45 +02:00
Bruno BELANYI ee916a506b build: makefile: add deploy step
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2021-08-08 16:23:51 +02:00
3 changed files with 40 additions and 33 deletions

View file

@ -1,58 +1,55 @@
local Pipeline(isDev) = {
kind: "pipeline",
name: if isDev then "deploy-dev" else "deploy-prod",
type: "exec",
name: if isDev then "Deploy to dev" else "Deploy to prod",
# Dev ignores "master", prod only triggers on "master"
trigger: { branch: { [if isDev then "exclude" else "include"]: [ "main" ] } },
# We want to clone the submodules, which isn't done by default
clone: { disable: true },
steps: [
{
name: "clone",
image: "plugins/git",
recursive: true,
# We want to clone the submodules, which isn't done by default
name: "submodules",
commands: [
"git submodule update --recursive --init",
]
},
{
name: "markdownlint",
image: "06kellyjac/markdownlint-cli",
# Include pre-commit checks, which include markdownlint
name: "check",
commands: [
"markdownlint --version",
"markdownlint content/",
"nix flake check",
],
},
{
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 "",
name: "build",
commands: [
"nix develop -c make " + if isDev then "build-dev" else "build-prod",
],
[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" },
commands: [
"nix develop -c make deploy",
],
environment: {
SSH_HOST: { from_secret: "ssh_host" },
SSH_TARGET: { from_secret: "ssh_target" + if isDev then "_dev" else "" },
SSH_USER: { from_secret: "ssh_user" },
SSH_KEY: { from_secret: "ssh_key" },
},
},
{
name: "notify",
image: "plugins/matrix",
settings: {
homeserver: { from_secret: "matrix_homeserver" },
roomid: { from_secret: "matrix_roomid" },
username: { from_secret: "matrix_username" },
password: { from_secret: "matrix_password" },
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" },
},
trigger: { status: [ "failure", "success", ] },
when: { status: [ "failure", "success", ] },
},
]
};

View file

@ -3,7 +3,7 @@ all: build-dev
.PHONY: build-dev
build-dev:
HUGO_BASEURL=https://dev.belanyi.fr hugo -D -F
HUGO_TITLE="Ambroisie's dev blog" HUGO_BASEURL=https://dev.belanyi.fr hugo -D -F
.PHONY: build-prod
build-prod:
@ -13,6 +13,14 @@ build-prod:
serve:
hugo server -D -F
deploy:
@if [ -n "$$SSH_KEY" ]; then eval "$$(ssh-agent)"; echo "$$SSH_KEY" | ssh-add -; fi
@if [ -z "$$SSH_USER" ] || [ -z "$$SSH_HOST" ] || [ -z "$$SSH_TARGET" ]; \
then echo "Missing one of SSH_USER, SSH_HOST, or SSH_TARGET" >&2; \
exit 1; \
fi
rsync --progress -avz --delete public/ "$$SSH_USER@$$SSH_HOST:$$SSH_TARGET"
.PHONY: clean
clean:
$(RM) -r public

View file

@ -67,6 +67,8 @@
buildInputs = with pkgs; [
gnumake
hugo
openssh
rsync
];
inherit (self.checks.${system}.pre-commit) shellHook;