forked from Azure/bicep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublishExamplesToRegistry.ps1
46 lines (36 loc) · 986 Bytes
/
PublishExamplesToRegistry.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
param (
[Parameter(Mandatory = $true)]
[string]
$BicepPath,
[Parameter(Mandatory = $true)]
[string]
$ExamplesPath,
[Parameter(Mandatory = $true)]
[string]
$Tag
)
$ErrorActionPreference = 'Stop';
$previousLocation = Get-Location;
try
{
Set-Location $BicepPath;
$levelDirs = Get-ChildItem -Path $ExamplesPath;
foreach ($levelDir in $levelDirs) {
$moduleDirs = Get-ChildItem -Path $levelDir.FullName;
foreach ($moduleDir in $moduleDirs) {
$bicep = Join-Path -Path $moduleDir.Fullname -ChildPath 'main.bicep';
$json = Join-Path -Path $moduleDir.Fullname -ChildPath 'main.json';
if((Test-Path $bicep) -and (Test-Path $json))
{
$artifactRef = "br:majastrzoci.azurecr.io/examples/$($levelDir.Name)/$($moduleDir.Name):$($Tag)";
Write-Output $artifactRef;
.\bicep.exe publish $bicep --target $artifactRef
}
}
}
}
finally
{
# restore previous location
Set-Location $previousLocation;
}