action-create-pr: init
This commit is contained in:
parent
53b5671d00
commit
2f15217d81
25
flake-parts/action-create-pr/default.nix
Normal file
25
flake-parts/action-create-pr/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
perSystem =
|
||||
{ config
|
||||
, pkgs
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
name = builtins.baseNameOf ./.;
|
||||
script = config.writers.writePureShellScriptBin
|
||||
name
|
||||
[
|
||||
pkgs.bash
|
||||
pkgs.coreutils
|
||||
pkgs.git
|
||||
pkgs.tea
|
||||
pkgs.openssh
|
||||
]
|
||||
''
|
||||
bash ${./script.sh}
|
||||
'';
|
||||
in
|
||||
{
|
||||
packages.${name} = script;
|
||||
};
|
||||
}
|
18
flake-parts/action-create-pr/script.sh
Normal file
18
flake-parts/action-create-pr/script.sh
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REMOTE_BRANCH="${REMOTE_BRANCH:-auto-pr}"
|
||||
PR_TITLE="${PR_TITLE:-'This PR was created automatically'}"
|
||||
|
||||
git diff --quiet || {
|
||||
echo -e "\e[31mWorking tree is dirty, please commit first\e[0m"
|
||||
git status
|
||||
exit 1
|
||||
}
|
||||
|
||||
git push origin "HEAD:$REMOTE_BRANCH"
|
||||
|
||||
tea pr create \
|
||||
--head "$REMOTE_BRANCH" \
|
||||
--labels "0.kind: automation" \
|
||||
--title "$PR_TITLE"
|
Loading…
Reference in New Issue
Block a user