ci: improve the pipelines

This commit is contained in:
silver 2023-08-07 03:03:46 +01:00
parent 5c62e7ede5
commit a55e963a6f

View file

@ -4,6 +4,7 @@ stages:
- flake - flake
- test - test
- deploy - deploy
- deploy_gitlab
# Update the flake for any changes upstream # Update the flake for any changes upstream
# Passed in from upstream # Passed in from upstream
@ -39,27 +40,8 @@ update:
variables: variables:
- $UPDATE_FLAKE == "yes" - $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 # every commit on main will build and deploy
deploy: .build_template: &build
stage: deploy
tags: tags:
- nix - nix
before_script: before_script:
@ -71,11 +53,6 @@ deploy:
# load nix environment # load nix environment
- . "$HOME/.nix-profile/etc/profile.d/nix.sh" - . "$HOME/.nix-profile/etc/profile.d/nix.sh"
- git pull origin main - 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: only:
refs: refs:
- main - main
@ -86,19 +63,38 @@ deploy:
- flake.* - flake.*
- .gitlab-ci.yml - .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 stage: deploy
tags: script:
- nix - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-dns
before_script:
# setup ssh key deploy_core:
- eval $(ssh-agent -s) <<: *build
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null stage: deploy
- mkdir -p ~/.ssh needs:
- chmod 700 ~/.ssh - deploy_dns
# load nix environment script:
- . "$HOME/.nix-profile/etc/profile.d/nix.sh" - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-core
- git pull origin main
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: script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-gitlab - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-gitlab
when: manual when: manual