Is it possible to use the same Git repository across multiple environments with Git sync?

Is it possible to use the same Git repository across multiple environments with Git sync?

avatar
(anonymous user)
Product: PowerShell Universal
Version: 4.0.10


I would like to use the same Git repository for non-production and production environments, but the PowerShell Universal repository contains some environment-specific configuration (such as SAML config in authentication.ps1).

Eventually, I want to have a more traditional deployment pipeline handling the separation of environment-specific configuration and the rest of the code, but I’m curious if this is something I can accomplish with the built-in Git Sync feature.

If I add a file like ./.universal/authentication.ps1 to gitignore, would I then be able to manage a separate version in each environment while still syncing the rest of the repository?

All Comments (4)

avatar

We ran into a similar setup and ended up using the same code base for dev/test/prod but using the PSUHeader region for the .universal files.

for example in the variables.ps1 I have the following.

#region PSUHeader
switch ($ENV:COMPUTERNAME) {
	"PSU1" { 
		$Environment = "Prod"
		$CurrentHostName = "https://hostname.com" 
	}
	"PSU2" {
		$Environment = "Test"
		$CurrentHostName = "https://hostname.com
	}
	Default { 
		$Environment = "Dev"
		$CurrentHostName = "http://localhost:5000" 
	}
}

New-PSUVariable -Name "HostName" -Value $CurrentHostName -Description "Hostname of the PSU instance"
New-PSUVariable -Name "Environment" -Value $Environment -Description "PSU environment type"
#endregion


avatar

Awesome! I was also wondering if this would work. Haven’t had a moment to try it or gitignore yet, but I like this approach better. Thank you.

avatar
as also wondering if this would

This isn’t perfect, so when you configure this PSU will show the vars, but if you change the variables, such as making a new one and saving through the UI, you will see duplicates.

@Adam Driscoll - Any thoughts on this approach?

avatar

Yeah, I’ve noticed the duplicates. I’m up to five now.