From eb321e4f05adb7442d15c0504be6a0a4b24b89b1 Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 26 Jul 2023 19:49:17 +0200 Subject: [PATCH] job-flake-update: init --- flake-parts/job-flake-update/default.nix | 26 ++++++++++++++++++++++++ flake-parts/job-flake-update/script.sh | 16 +++++++++++++++ flake.nix | 1 + 3 files changed, 43 insertions(+) create mode 100644 flake-parts/job-flake-update/default.nix create mode 100644 flake-parts/job-flake-update/script.sh diff --git a/flake-parts/job-flake-update/default.nix b/flake-parts/job-flake-update/default.nix new file mode 100644 index 0000000..33029ab --- /dev/null +++ b/flake-parts/job-flake-update/default.nix @@ -0,0 +1,26 @@ +{ + perSystem = + { config + , pkgs + , self' + , ... + }: + let + name = builtins.baseNameOf ./.; + script = config.writers.writePureShellScriptBin + name + [ + pkgs.bash + pkgs.coreutils + self'.packages.action-checkout + self'.packages.action-flake-update + self'.packages.action-create-pr + ] + '' + bash ${./script.sh} + ''; + in + { + packages.${name} = script; + }; +} diff --git a/flake-parts/job-flake-update/script.sh b/flake-parts/job-flake-update/script.sh new file mode 100644 index 0000000..3c1c6a9 --- /dev/null +++ b/flake-parts/job-flake-update/script.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +# prevent these variables from being unset by writePureShellScript +export KEEP_VARS="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_DIR=$TMPDIR/repo + +action-checkout +cd $REPO_DIR +action-flake-update +action-create-pr diff --git a/flake.nix b/flake.nix index 379d503..f442912 100644 --- a/flake.nix +++ b/flake.nix @@ -45,6 +45,7 @@ ./flake-parts/action-checkout ./flake-parts/action-flake-update ./flake-parts/action-create-pr + ./flake-parts/job-flake-update ./targets/flake-module.nix ./modules/flake-module.nix ./pkgs/flake-module.nix