Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ jobs:

- name: Install azsdk mcp server
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./eng/common/mcp/azure-sdk-mcp.ps1 -InstallDirectory $HOME/bin
34 changes: 32 additions & 2 deletions eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@ function isNewVersion(
return $true
}

function Get-GitHubApiHeaders {
# Use GitHub cli to get an auth token if available
if (Get-Command gh -ErrorAction SilentlyContinue) {
$token = gh auth token 2>$null
}

# Get token from env if not available from gh cli
if (!$token)
{
Write-Host "Check for GITHUB_TOKEN environment variable."
$token = $env:GITHUB_TOKEN
}

if ($token)
{
Write-Host "Using authenticated GitHub API requests."
$headers = @{
Authorization = "Bearer $tokentest"
}
return $headers
}

Write-Host "Using unauthenticated GitHub API requests."
$headers = @{
Authorization = "Bearer testfail"
}
return $headers
}

<#
.SYNOPSIS
Installs a standalone version of an engsys tool.
Expand Down Expand Up @@ -135,11 +164,12 @@ function Install-Standalone-Tool (
}

$tag = "${Package}_${Version}"
$headers = Get-GitHubApiHeaders

if (!$Version -or $Version -eq "*") {
Write-Host "Attempting to find latest version for package '$Package'"
$releasesUrl = "https://api.github.com/repos/$Repository/releases"
$releases = Invoke-RestMethod -Uri $releasesUrl
$releases = Invoke-RestMethod -Uri $releasesUrl -Headers $headers
$found = $false
foreach ($release in $releases) {
if ($release.tag_name -like "$Package*") {
Expand All @@ -163,7 +193,7 @@ function Install-Standalone-Tool (

if (isNewVersion $version $downloadFolder) {
Write-Host "Installing '$Package' '$Version' to '$downloadFolder' from $downloadUrl"
Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadLocation
Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadLocation -Headers $headers

if ($downloadFile -like "*.zip") {
Expand-Archive -Path $downloadLocation -DestinationPath $downloadFolder -Force
Expand Down
Loading