ci: test woodpecker
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-10-24 00:58:11 +05:30
parent 2233f70332
commit c88c5d797d
2 changed files with 40 additions and 7 deletions

20
.woodpecker/ci.yml Normal file
View File

@@ -0,0 +1,20 @@
pipeline:
build-and-deploy:
image: nixos/nix:latest
environment:
- TARGET_HOST=weirdnatto.in
- TARGET_PORT=22001
commands:
- nix-env -iA nixpkgs.cachix nixpkgs.rsync nixpkgs.jq
- cachix use $CACHIX_NAME
- nix --extra-experimental-features "nix-command flakes" -L build -o site
| jq -r '.[].outputs | to_entries[].value'
| cachix push $CACHIX_NAME
- eval `ssh-agent -s`
- mkdir -p ~/.ssh
- ssh-keyscan -p $TARGET_PORT $TARGET_HOST >> ~/.ssh/known_hosts
- echo "$REMOTE_KEY" | ssh-add -
- rsync --checksum -ave "ssh -p $TARGET_PORT"
site/* root@$TARGET_HOST:/var/lib/site
secrets: [ cachix_auth_token, cachix_name, remote_key ]

View File

@@ -13,21 +13,34 @@
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs.lib.sources) cleanSourceWith cleanSource;
filterCI = name: type:
!((type == "directory") && (baseNameOf name == ".woodpecker"));
cleanSrc = cleanSourceWith {
filter = filterCI;
src = cleanSource ./.;
};
vars = pkgs.lib.mapAttrsToList (n: v: "export ${n}=${v}") {
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
LANG = "en_US.UTF-8";
};
site = pkgs.haskellPackages.callCabal2nix "nattopages" ./src { };
nattopages = pkgs.stdenv.mkDerivation {
name = "nattopages";
src = ./.;
src = cleanSrc;
phases = "unpackPhase buildPhase";
nativeBuildInputs = [ site ];
buildPhase = (pkgs.lib.concatStringsSep "\n" vars ) + ''
mkdir -p $out
cp -r \_site/* $out
'';
buildPhase = (pkgs.lib.concatStringsSep "\n" vars) + "\n" +
''
site build
mkdir -p $out
cp -r _site/* $out
'';
};
in
rec {