From a3e8d80c50ee1f02b4a7b95917e4634896047e4d Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Wed, 9 Aug 2023 20:27:04 +0100 Subject: [PATCH] ci: only run the scripts that need envs to be added on main --- .gitlab-ci.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b9823a..195fb79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,19 +40,24 @@ update: variables: - $UPDATE_FLAKE == "yes" +.scripts_base: &scripts_base + # load nix environment + - . "$HOME/.nix-profile/etc/profile.d/nix.sh" + - git pull origin main + +.scripts_deploy: &scripts_deploy + # setup ssh key + - eval $(ssh-agent -s) + - echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + # every commit on main will build and deploy .build_template: &builder tags: - nix before_script: - # setup ssh key - - eval $(ssh-agent -s) - - echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - # load nix environment - - . "$HOME/.nix-profile/etc/profile.d/nix.sh" - - git pull origin main + - *scripts_base only: changes: - applications/**/* @@ -63,6 +68,9 @@ update: # deploy items only run on main .deploy_template: &deployment + before_script: + - *scripts_deploy + - *scripts_base only: refs: - main