diff --git a/docs/content/specs/shared/_index.md b/docs/content/specs/shared/_index.md index 678f70ec8..e57f93066 100644 --- a/docs/content/specs/shared/_index.md +++ b/docs/content/specs/shared/_index.md @@ -667,8 +667,32 @@ For most scenario this is the command you'll need to call the below PowerShell s Set-AvmGitHubLabels.ps1 -RepositoryName "Org/MyGitHubRepo" -CreateCsvLabelExports $false -NoUserPrompts $true ``` +```shell +# Linux / MacOs +# For Windows replace $PWD with your the local path or your repository +# +docker run -it -v $PWD:/repo -w /repo mcr.microsoft.com/powershell pwsh -Command ' + #Invoke-WebRequest -Uri "https://azure.github.io/Azure-Verified-Modules/scripts/Set-AvmGitHubLabels.ps1" -OutFile "Set-AvmGitHubLabels.ps1" + $gh_version = "2.44.1" + Invoke-WebRequest -Uri "https://github.com/cli/cli/releases/download/v2.44.1/gh_2.44.1_linux_amd64.tar.gz" -OutFile "gh_$($gh_version)_linux_amd64.tar.gz" + apt-get update && apt-get install -y git + tar -xzf "gh_$($gh_version)_linux_amd64.tar.gz" + ls -lsa + mv "gh_$($gh_version)_linux_amd64/bin/gh" /usr/local/bin/ + rm "gh_$($gh_version)_linux_amd64.tar.gz" && rm -rf "gh_$($gh_version)_linux_amd64" + gh --version + ls -lsa + gh auth login + $OrgProject = "Azure/terraform-azurerm-avm-res-kusto-cluster" + gh auth status + ./Set-AvmGitHubLabels.ps1 -RepositoryName $OrgProject -CreateCsvLabelExports $false -NoUserPrompts $true + ' +``` + By default this script will only update and append labels on the repository specified. However, this can be changed by setting the parameter `-UpdateAndAddLabelsOnly` to `$false`, which will remove all the labels from the repository first and then apply the AVM labels from the CSV only. +Make sure you elevate your privilege to admin level or the labels will not be applied to your repository. Go to repos.opensource.microsoft.com/orgs/Azure/repos/ to request admin access before running the script. + Full Script: These `Set-AvmGitHubLabels.ps1` can be downloaded from here. diff --git a/docs/static/scripts/Set-AvmGitHubLabels.ps1 b/docs/static/scripts/Set-AvmGitHubLabels.ps1 index 62407287a..ba677ff8c 100644 --- a/docs/static/scripts/Set-AvmGitHubLabels.ps1 +++ b/docs/static/scripts/Set-AvmGitHubLabels.ps1 @@ -116,7 +116,8 @@ Write-Host "The GitHub CLI is installed..." -ForegroundColor Green # Check if GitHub CLI is authenticated $GitHubCliAuthenticated = gh auth status -if ($null -eq $GitHubCliAuthenticated) { +if ($LASTEXITCODE -ne 0) { + Write-Host $GitHubCliAuthenticated -ForegroundColor Red throw "Not authenticated to GitHub. Please authenticate to GitHub using the GitHub CLI, `gh auth login`, and try again." } Write-Host "Authenticated to GitHub..." -ForegroundColor Green @@ -129,7 +130,8 @@ if ($false -eq $GitHubRepositoryNameValid) { # List GitHub repository provided and check it exists $GitHubRepository = gh repo view $RepositoryName -if ($null -eq $GitHubRepository) { +if ($LASTEXITCODE -ne 0) { + Write-Host $GitHubRepository -ForegroundColor Red throw "The GitHub repository $RepositoryName does not exist. Please check the repository name and try again." } Write-Host "The GitHub repository $RepositoryName exists..." -ForegroundColor Green