replace deploy-rs CI with Comin pull-based deployment
- Add Comin service for cryodev-main (polls git repo, auto-deploys) - Fix cryodev-pi Comin URL (cryodev-server.git -> cryodev.git) - Remove deploy-rs from CI pipeline (was insecure with shared runner) - Remove deploy SSH key, root SSH login, sudo rules for gitea-runner - Revert PermitRootLogin back to 'no' - CI now only runs flake-check + build (no deploy) - Deployment happens via Comin (both hosts poll and self-deploy)
This commit is contained in:
parent
ed806bf5fb
commit
c45a603d1c
11 changed files with 37 additions and 50 deletions
|
|
@ -15,38 +15,18 @@ jobs:
|
||||||
- name: Run flake check
|
- name: Run flake check
|
||||||
run: nix flake check --impure
|
run: nix flake check --impure
|
||||||
|
|
||||||
deploy-cryodev-main:
|
build-hosts:
|
||||||
needs: flake-check
|
needs: flake-check
|
||||||
runs-on: host
|
runs-on: host
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up SSH
|
- name: Build cryodev-main
|
||||||
env:
|
run: nix build .#nixosConfigurations.cryodev-main.config.system.build.toplevel --impure
|
||||||
DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
||||||
run: |
|
|
||||||
# Write key to a shared location readable by nix-daemon
|
|
||||||
sudo mkdir -p /etc/deploy
|
|
||||||
echo "$DEPLOY_KEY" | sudo tee /etc/deploy/key > /dev/null
|
|
||||||
sudo chmod 600 /etc/deploy/key
|
|
||||||
|
|
||||||
# Global SSH config so both the runner and nix-daemon can use it
|
- name: Build cryodev-pi
|
||||||
sudo tee /etc/ssh/ssh_config.d/deploy.conf > /dev/null << 'EOF'
|
run: nix build .#nixosConfigurations.cryodev-pi.config.system.build.toplevel --impure
|
||||||
Host cryodev.xyz
|
|
||||||
Port 2299
|
|
||||||
User root
|
|
||||||
IdentityFile /etc/deploy/key
|
|
||||||
StrictHostKeyChecking accept-new
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Deploy with deploy-rs
|
|
||||||
run: nix run github:serokell/deploy-rs -- -s .#cryodev-main
|
|
||||||
|
|
||||||
- name: Clean up SSH
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
sudo rm -f /etc/deploy/key /etc/ssh/ssh_config.d/deploy.conf
|
|
||||||
|
|
||||||
build-pi-images:
|
build-pi-images:
|
||||||
needs: flake-check
|
needs: flake-check
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
||||||
result
|
result
|
||||||
result-*
|
result-*
|
||||||
|
sid.ovh
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,6 @@
|
||||||
sshOpts = [
|
sshOpts = [
|
||||||
"-p"
|
"-p"
|
||||||
"2299"
|
"2299"
|
||||||
"-o"
|
|
||||||
"StrictHostKeyChecking=accept-new"
|
|
||||||
];
|
];
|
||||||
profiles.system = {
|
profiles.system = {
|
||||||
user = "root";
|
user = "root";
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFIPGMqOV+YrGle8X7/hctW4Sha/bzeTsTP9AcDN9bA2 forgejo-deploy
|
|
||||||
24
hosts/cryodev-main/services/comin.nix
Normal file
24
hosts/cryodev-main/services/comin.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
outputs,
|
||||||
|
constants,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
outputs.nixosModules.comin
|
||||||
|
];
|
||||||
|
|
||||||
|
services.comin = {
|
||||||
|
enable = true;
|
||||||
|
remotes = [
|
||||||
|
{
|
||||||
|
name = "origin";
|
||||||
|
url = "https://${constants.services.forgejo.fqdn}/steffen/cryodev.git";
|
||||||
|
branches.main.name = "main";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# Stufe 1: Services ohne externe Abhaengigkeiten
|
./comin.nix
|
||||||
./forgejo.nix
|
./forgejo.nix
|
||||||
|
./forgejo-runner.nix
|
||||||
|
./headplane.nix
|
||||||
./headscale.nix
|
./headscale.nix
|
||||||
./mailserver.nix
|
./mailserver.nix
|
||||||
./netdata.nix
|
./netdata.nix
|
||||||
./nginx.nix
|
./nginx.nix
|
||||||
./openssh.nix
|
./openssh.nix
|
||||||
./sops.nix
|
./sops.nix
|
||||||
|
./tailscale.nix
|
||||||
# Stufe 2: Erst aktivieren wenn Headscale/Forgejo laufen und echte Secrets existieren
|
|
||||||
./forgejo-runner.nix # braucht: forgejo-runner/token (Forgejo)
|
|
||||||
./headplane.nix # braucht: headplane/agent_pre_authkey (Headscale)
|
|
||||||
./tailscale.nix # braucht: tailscale/auth-key (Headscale)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,4 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
|
|
||||||
# Root SSH key for deploy-rs (key-only, no password)
|
|
||||||
users.users.root.openssh.authorizedKeys.keyFiles = [
|
|
||||||
../deploy-key.pub
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
remotes = [
|
remotes = [
|
||||||
{
|
{
|
||||||
name = "origin";
|
name = "origin";
|
||||||
url = "https://${constants.services.forgejo.fqdn}/steffen/cryodev-server.git";
|
url = "https://${constants.services.forgejo.fqdn}/steffen/cryodev.git";
|
||||||
branches.main.name = "main";
|
branches.main.name = "main";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,6 @@ in
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
nix.settings.trusted-users = [ "gitea-runner" ];
|
nix.settings.trusted-users = [ "gitea-runner" ];
|
||||||
|
|
||||||
# Allow gitea-runner to manage deploy keys and SSH config for CI/CD
|
|
||||||
security.sudo.extraConfig = ''
|
|
||||||
gitea-runner ALL=(root) NOPASSWD: /run/current-system/sw/bin/tee /etc/deploy/key
|
|
||||||
gitea-runner ALL=(root) NOPASSWD: /run/current-system/sw/bin/tee /etc/ssh/ssh_config.d/deploy.conf
|
|
||||||
gitea-runner ALL=(root) NOPASSWD: /run/current-system/sw/bin/mkdir -p /etc/deploy
|
|
||||||
gitea-runner ALL=(root) NOPASSWD: /run/current-system/sw/bin/chmod 600 /etc/deploy/key
|
|
||||||
gitea-runner ALL=(root) NOPASSWD: /run/current-system/sw/bin/rm -f /etc/deploy/key /etc/ssh/ssh_config.d/deploy.conf
|
|
||||||
'';
|
|
||||||
|
|
||||||
services.gitea-actions-runner = {
|
services.gitea-actions-runner = {
|
||||||
package = pkgs.forgejo-runner;
|
package = pkgs.forgejo-runner;
|
||||||
instances.default = {
|
instances.default = {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ in
|
||||||
ports = mkDefault [ 2299 ];
|
ports = mkDefault [ 2299 ];
|
||||||
openFirewall = mkDefault true;
|
openFirewall = mkDefault true;
|
||||||
settings = {
|
settings = {
|
||||||
PermitRootLogin = mkDefault "prohibit-password";
|
PermitRootLogin = mkDefault "no";
|
||||||
PasswordAuthentication = mkDefault false;
|
PasswordAuthentication = mkDefault false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
1
sid.ovh
Submodule
1
sid.ovh
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 197c8246234c1237b251d51d1bd54bcc9c1ba1d4
|
||||||
Loading…
Add table
Add a link
Reference in a new issue