From a55e963a6ff54f696230a08c3aaa2604a015c5be Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 7 Aug 2023 03:03:46 +0100 Subject: [PATCH] ci: improve the pipelines --- .gitlab-ci.yml | 70 ++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b79fe8..bdc2e47 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ stages: - flake - test - deploy + - deploy_gitlab # Update the flake for any changes upstream # Passed in from upstream @@ -39,27 +40,8 @@ update: variables: - $UPDATE_FLAKE == "yes" -build: - stage: test - tags: - - nix - before_script: - - . "$HOME/.nix-profile/etc/profile.d/nix.sh" - # use the new flake - - git pull origin main - script: - - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- build - only: - changes: - - applications/**/* - - machines/**/* - - secrets/**/* - - flake.* - - .gitlab-ci.yml - # every commit on main will build and deploy -deploy: - stage: deploy +.build_template: &build tags: - nix before_script: @@ -71,11 +53,6 @@ deploy: # load nix environment - . "$HOME/.nix-profile/etc/profile.d/nix.sh" - git pull origin main - script: - # dns is always deployed first - - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-dns - - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-core - - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active only: refs: - main @@ -86,19 +63,38 @@ deploy: - flake.* - .gitlab-ci.yml -deploy_gitlab: +build: + <<: *build + stage: test + script: + - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- build + +# dns always has to be deployed first +deploy_dns: + <<: *build stage: deploy - 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 + script: + - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-dns + +deploy_core: + <<: *build + stage: deploy + needs: + - deploy_dns + script: + - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-core + +deploy_active: + <<: *build + stage: deploy + needs: + - deploy_dns + script: + - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active + +deploy_gitlab: + <<: *build + stage: deploy_gitlab script: - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-gitlab when: manual \ No newline at end of file