add actions and jobs for automatic updates #38

Merged
clan-bot merged 11 commits from actions into main 2023-07-28 12:03:45 +00:00
3 changed files with 48 additions and 2 deletions
Showing only changes of commit 7aedda8aea - Show all commits

View File

@ -2,12 +2,12 @@
set -euo pipefail
# prevent these variables from being unset by writePureShellScript
export KEEP_VARS="PR_TITLE REMOTE_BRANCH REPO REPO_DIR"
export KEEP_VARS="GIT_AUTHOR_NAME GIT_COMMITTER_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_EMAIL PR_TITLE REMOTE_BRANCH REPO REPO_DIR"
# configure variables for actions
export PR_TITLE="Automatic flake update - $(date --iso-8601=minutes)"
export REMOTE_BRANCH="flake-update-$(date --iso-8601)"
export REPO=gitea@git.clan.lol:clan/clan-infra.git
export REPO="https://git.clan.lol/clan/clan-infra"
export REPO_DIR=$TMPDIR/repo
action-checkout

View File

@ -7,6 +7,7 @@
./harmonia.nix
./homepage.nix
./postfix.nix
./job-flake-update.nix
../zerotier
../zerotier/ctrl.nix
];

View File

@ -0,0 +1,45 @@
{ config, self, pkgs, ... }: {
sops.secrets.merge-bot-gitea-token = { };
systemd.timers.job-flake-update = {
description = "Time for flake update workflow";
partOf = [ "job-flake-update.service" ];
wantedBy = [ "timers.target" ];
timerConfig = {
Persistent = true;
OnCalendar = "daily";
};
after = [ "network-online.target" ];
};
# service to for automatic merge bot
systemd.services.job-flake-update = {
description = "Automatically update flake inputs for clan-repos";
after = [ "network-online.target" ];
environment = {
GITEA_TOKEN_FILE = "%d/GITEA_TOKEN_FILE";
# these ariables are repescted by git itself
GIT_AUTHOR_NAME = "Clan Merge Bot";
GIT_COMMITTER_NAME = "Clan Merge Bot";
GIT_AUTHOR_EMAIL = "clan-bot@git.clan.lol";
GIT_COMMITTER_EMAIL = "clan-bot@git.clan.lol";
DavHau marked this conversation as resolved Outdated
Outdated
Review

HOME = "/run/job-flake-update";
REPO_DIR = "/run/job-flake-update/repo";

HOME = "/run/job-flake-update"; REPO_DIR = "/run/job-flake-update/repo";
};
serviceConfig = {
LoadCredential = [ "GITEA_TOKEN_FILE:${config.sops.secrets.merge-bot-gitea-token.path}" ];
DynamicUser = true;
RuntimeDirectory = "job-flake-update";
};
path = [
self.packages.${pkgs.system}.job-flake-update
self.packages.${pkgs.system}.job-flake-update
DavHau marked this conversation as resolved Outdated
Outdated
Review

Twice?

Twice?
];
script = ''
cd /run/job-flake-update
DavHau marked this conversation as resolved Outdated
Outdated
Review

You can use serviceConfig.WorkingDirectory instead.

You can use serviceConfig.WorkingDirectory instead.
mkdir -p home
export HOME=$(realpath home)
export REPO_DIR=$HOME/repo
DavHau marked this conversation as resolved Outdated
Outdated
Review

If you move environment variables as suggested above, you can use ExecStart on self.packages.${pkgs.system}.job-flake-update instead of having to generate a wrapper script

If you move environment variables as suggested above, you can use ExecStart on self.packages.${pkgs.system}.job-flake-update instead of having to generate a wrapper script
job-flake-update
'';
};
}