mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2026-02-02 03:15:09 +01:00
chore(utils): fix before_script getting overwritten and add collapsible sections
This commit is contained in:
parent
93baeca411
commit
f460960ce6
2 changed files with 40 additions and 37 deletions
25
utils.nix
25
utils.nix
|
|
@ -6,8 +6,11 @@
|
||||||
}: jobArgs:
|
}: jobArgs:
|
||||||
jobArgs
|
jobArgs
|
||||||
// {
|
// {
|
||||||
before_script = [
|
before_script =
|
||||||
|
(jobArgs.before_script or [])
|
||||||
|
++ [
|
||||||
''
|
''
|
||||||
|
echo -e "\\e[0Ksection_start:`date +%s`:commit_setup[collapsed=true]\\r\\e[0KSetting up commitAndPushFiles"
|
||||||
eval "$(ssh-agent -s)" >/dev/null;
|
eval "$(ssh-agent -s)" >/dev/null;
|
||||||
mkdir -p ~/.ssh; touch ~/.ssh/known_hosts;
|
mkdir -p ~/.ssh; touch ~/.ssh/known_hosts;
|
||||||
ssh-keyscan -t rsa $CI_SERVER_HOST >> ~/.ssh/known_hosts;
|
ssh-keyscan -t rsa $CI_SERVER_HOST >> ~/.ssh/known_hosts;
|
||||||
|
|
@ -16,25 +19,25 @@
|
||||||
git config --global user.name "$GIT_NAME" >/dev/null;
|
git config --global user.name "$GIT_NAME" >/dev/null;
|
||||||
export CI_PUSH_REPO=`echo $CI_REPOSITORY_URL | sed -e "s|.*@\(.*\)|git@\1|" -e "s|/|:|"`;
|
export CI_PUSH_REPO=`echo $CI_REPOSITORY_URL | sed -e "s|.*@\(.*\)|git@\1|" -e "s|/|:|"`;
|
||||||
git remote rm origin && git remote add origin ''${CI_PUSH_REPO}
|
git remote rm origin && git remote add origin ''${CI_PUSH_REPO}
|
||||||
|
echo -e "\\e[0Ksection_end:`date +%s`:commit_setup\\r\\e[0K"
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
script =
|
script = let
|
||||||
(jobArgs.script or [])
|
addScript =
|
||||||
++ (
|
|
||||||
if builtins.length files == 0
|
if builtins.length files == 0
|
||||||
then []
|
then ""
|
||||||
else [
|
else "git add ${builtins.concatStringsSep " " files}";
|
||||||
''
|
in
|
||||||
git add ${builtins.concatStringsSep " " files}
|
(jobArgs.script or [])
|
||||||
''
|
|
||||||
]
|
|
||||||
)
|
|
||||||
++ [
|
++ [
|
||||||
''
|
''
|
||||||
|
echo -e "\\e[0Ksection_start:`date +%s`:commit[collapsed=true]\\r\\e[0KCommiting & pushing changes if necessary"
|
||||||
|
${addScript}
|
||||||
git diff --cached --exit-code >/dev/null &&
|
git diff --cached --exit-code >/dev/null &&
|
||||||
echo "Nothing to commit" ||
|
echo "Nothing to commit" ||
|
||||||
git commit -m "${message}" --no-verify;
|
git commit -m "${message}" --no-verify;
|
||||||
git push --tags origin ''${GIT_SOURCE_REF:-HEAD}:''${GIT_TARGET_REF:-$CI_COMMIT_REF_NAME} -o ci.skip
|
git push --tags origin ''${GIT_SOURCE_REF:-HEAD}:''${GIT_TARGET_REF:-$CI_COMMIT_REF_NAME} -o ci.skip
|
||||||
|
echo -e "\\e[0Ksection_end:`date +%s`:commit\\r\\e[0K"
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
deps = (jobArgs.deps or []) ++ [pkgs.openssh pkgs.gitMinimal pkgs.gnused];
|
deps = (jobArgs.deps or []) ++ [pkgs.openssh pkgs.gitMinimal pkgs.gnused];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue