-
Notifications
You must be signed in to change notification settings - Fork 730
/
install_vsix_nightly.ps1
33 lines (27 loc) · 925 Bytes
/
install_vsix_nightly.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
[cmdletbinding()]
param(
[string]$RunId,
[string]$Branch,
[string]$Repo
)
$ErrorActionPreference="Stop"
if ((Get-Command "gh" -ErrorAction SilentlyContinue) -eq $null) {
throw "Please install the GitHub CLI: https://cli.github.com/"
}
# Fetch
if (!$Repo) {
$Repo = "Azure/bicep"
}
if (!$Branch) {
$Branch = "main"
}
if (!$RunId) {
$RunId = & gh run list -R $Repo --branch $Branch --workflow build --status success -L 1 --json databaseId -q ".[0].databaseId"; if(!$?) { throw }
}
$tmpDir = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
& gh run download -R $Repo $RunId -n "vscode-bicep.vsix" --dir $tmpDir; if(!$?) { throw }
# Install
& code --install-extension "$tmpDir/vscode-bicep.vsix" --force; if(!$?) { throw }
echo "Installed Bicep VSCode extension from https://github.com/$Repo/actions/runs/$RunId"
# Cleanup
Remove-Item $tmpDir -Recurse