Compare commits

...

16 commits

Author SHA1 Message Date
Bruno BELANYI 90049627c3 WIP
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-08 18:17:23 +02:00
Bruno BELANYI fbe490087b WIP
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 18:06:40 +02:00
Bruno BELANYI ff6f01534e fixup! fixup! e53ee2c5fa
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:53:15 +02:00
Bruno BELANYI 55d455cc6e fixup! e53ee2c5fa 2021-08-08 17:53:15 +02:00
Bruno BELANYI a10936a7ba fixup! e53ee2c5fa
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:51:09 +02:00
Bruno BELANYI e53ee2c5fa WIP
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:45:21 +02:00
Bruno BELANYI 4c699961ad fixup! build: makefile: add deploy step
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:42:00 +02:00
Bruno BELANYI 2e8ae92d87 WIP
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:36:02 +02:00
Bruno BELANYI 900d42d22f fixup! WIP
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:33:54 +02:00
Bruno BELANYI 0437b11413 WIP
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:29:00 +02:00
Bruno BELANYI e7b7c585cf fixup! fixup! build: makefile: add deploy step
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:23:09 +02:00
Bruno BELANYI 33fe7ee700 fixup! build: makefile: add deploy step
Some checks failed
continuous-integration/drone/push Build is failing
2021-08-08 17:20:55 +02:00
Bruno BELANYI e456e8977b WIP: nix: add openssh/rsync to dev shell 2021-08-08 17:15:30 +02:00
Bruno BELANYI b743fb2e68 build: makefile: change title on dev deployment 2021-08-08 17:14:47 +02:00
Bruno BELANYI c23858ac26 ci: use exec runner 2021-08-08 17:14:47 +02:00
Bruno BELANYI 4274671a23 build: makefile: add deploy step 2021-08-08 17:14:47 +02:00
3 changed files with 49 additions and 33 deletions

View file

@ -1,58 +1,60 @@
local Pipeline(isDev) = { local Pipeline(isDev) = {
kind: "pipeline", 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" # Dev ignores "master", prod only triggers on "master"
trigger: { branch: { [if isDev then "exclude" else "include"]: [ "main" ] } }, 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: [ steps: [
{ {
name: "clone", # We want to clone the submodules, which isn't done by default
image: "plugins/git", name: "submodules",
recursive: true, commands: [
"git submodule update --recursive --init",
]
}, },
{ {
name: "markdownlint", # Include pre-commit checks, which include markdownlint
image: "06kellyjac/markdownlint-cli", name: "check",
commands: [ commands: [
"markdownlint --version", "nix flake check",
"markdownlint content/",
], ],
}, },
{ {
name: "build",
image: "klakegg/hugo",
commands: [
"hugo version",
# If dev, include drafts and future articles, change base URL # 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", name: "deploy",
image: "appleboy/drone-scp", commands: [
settings: { "env",
source: "public/*", "nix run github:ambroisie/nix-config#drone-scp",
strip_components: 1, # Remove 'public/' suffix from file paths ],
rm: true, # Remove previous files from target directory environment: {
host: { from_secret: "ssh_host" }, SCP_SOURCE: "public/*",
target: { from_secret: "ssh_target" + if isDev then "_dev" else "" }, SCP_STRIP_COMPONENTS: 1, # Remove 'public/' suffix from file paths
username: { from_secret: "ssh_user" }, SCP_RM: true, # Remove previous files from target directory
key: { from_secret: "ssh_key" }, SCP_HOST: { from_secret: "ssh_host" },
port: { from_secret: "ssh_port" }, 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" },
}, },
}, },
{ {
name: "notify", name: "notify",
image: "plugins/matrix", commands: [
settings: { "nix run github:ambroisie/matrix-notifier",
homeserver: { from_secret: "matrix_homeserver" }, ],
roomid: { from_secret: "matrix_roomid" }, environment: {
username: { from_secret: "matrix_username" }, ADDRESS: { from_secret: "matrix_homeserver" },
password: { from_secret: "matrix_password" }, 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 .PHONY: build-dev
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 .PHONY: build-prod
build-prod: build-prod:
@ -13,6 +13,18 @@ build-prod:
serve: serve:
hugo server -D -F 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
mkdir -p ~/.ssh/
touch ~/.ssh/known_hosts
ssh-keygen -R "$$SSH_HOST" -f ~/.ssh/known_hosts
ssh-keyscan "$$SSH_HOST" >> ~/.ssh/known_hosts
rsync -e "ssh -o StrictHostKeyChecking=no" --progress -avz --delete public/ "$$SSH_USER@$$SSH_HOST:$$SSH_TARGET"
.PHONY: clean .PHONY: clean
clean: clean:
$(RM) -r public $(RM) -r public

View file

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