ci: improve it so some thigns only run on main

This commit is contained in:
silver 2023-08-09 20:12:43 +01:00
parent b0d7c51736
commit d5b96daa2c

View file

@ -41,7 +41,7 @@ update:
- $UPDATE_FLAKE == "yes" - $UPDATE_FLAKE == "yes"
# every commit on main will build and deploy # every commit on main will build and deploy
.build_template: &build .build_template: &builder
tags: tags:
- nix - nix
before_script: before_script:
@ -54,8 +54,6 @@ update:
- . "$HOME/.nix-profile/etc/profile.d/nix.sh" - . "$HOME/.nix-profile/etc/profile.d/nix.sh"
- git pull origin main - git pull origin main
only: only:
refs:
- main
changes: changes:
- applications/**/* - applications/**/*
- machines/**/* - machines/**/*
@ -63,21 +61,29 @@ update:
- flake.* - flake.*
- .gitlab-ci.yml - .gitlab-ci.yml
# deploy items only run on main
.deploy_template: &deployment
only:
refs:
- main
build: build:
<<: *build <<: *builder
stage: test stage: test
script: script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- build - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- build
# dns always has to be deployed first # dns always has to be deployed first
deploy_dns: deploy_dns:
<<: *build <<: *builder
<<: *deployment
stage: deploy stage: deploy
script: script:
- 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-dns
deploy_core: deploy_core:
<<: *build <<: *builder
<<: *deployment
stage: deploy stage: deploy
needs: needs:
- deploy_dns - deploy_dns
@ -85,7 +91,8 @@ deploy_core:
- 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-core
deploy_active: deploy_active:
<<: *build <<: *builder
<<: *deployment
stage: deploy stage: deploy
needs: needs:
- deploy_dns - deploy_dns
@ -93,7 +100,8 @@ deploy_active:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active - nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active
deploy_gitlab: deploy_gitlab:
<<: *build <<: *builder
<<: *deployment
stage: deploy_gitlab 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