Compare commits
5 commits
70a023df7a
...
33fe7ee700
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 33fe7ee700 | ||
Bruno BELANYI | e456e8977b | ||
Bruno BELANYI | b743fb2e68 | ||
Bruno BELANYI | c23858ac26 | ||
Bruno BELANYI | 4274671a23 |
|
@ -1,58 +1,55 @@
|
||||||
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/",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
# If dev, include drafts and future articles, change base URL
|
||||||
name: "build",
|
name: "build",
|
||||||
image: "klakegg/hugo",
|
|
||||||
commands: [
|
commands: [
|
||||||
"hugo version",
|
"nix develop -c make " + if isDev then "build-dev" else "build-prod",
|
||||||
# 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",
|
name: "deploy",
|
||||||
image: "appleboy/drone-scp",
|
commands: [
|
||||||
settings: {
|
"nix develop -c make deploy",
|
||||||
source: "public/*",
|
],
|
||||||
strip_components: 1, # Remove 'public/' suffix from file paths
|
environment: {
|
||||||
rm: true, # Remove previous files from target directory
|
SSH_HOST: { from_secret: "ssh_host" },
|
||||||
host: { from_secret: "ssh_host" },
|
SSH_TARGET: { from_secret: "ssh_target" + if isDev then "_dev" else "" },
|
||||||
target: { from_secret: "ssh_target" + if isDev then "_dev" else "" },
|
SSH_USER: { from_secret: "ssh_user" },
|
||||||
username: { from_secret: "ssh_user" },
|
SSH_KEY: { from_secret: "ssh_key" },
|
||||||
key: { from_secret: "ssh_key" },
|
|
||||||
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", ] },
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -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,14 @@ 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
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue