Skip to content

Commit

Permalink
jit
Browse files Browse the repository at this point in the history
  • Loading branch information
freddydk committed Nov 19, 2024
1 parent 85014aa commit cea8eda
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions e2eTests/e2eTestHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ function SetTokenAndRepository {

MaskValue -key "token" -value $token
$script:githubOwner = $githubOwner
$script:token = GetRealToken -token $token -repository "$githubOwner/.github"
$script:token = $token
$script:defaultRepository = $repository
$realToken = GetRealToken -token $script:token -repository "$githubOwner/.github"

if ($github) {
invoke-git config --global user.email "$githubOwner@users.noreply.github.com"
Expand All @@ -33,9 +34,9 @@ function SetTokenAndRepository {
$ENV:GITHUB_TOKEN = ''
}
Write-Host "Authenticating with GitHub using token"
$script:token | invoke-gh auth login --with-token
$realToken | invoke-gh auth login --with-token
if ($github) {
$ENV:GITHUB_TOKEN = $script:token
$ENV:GITHUB_TOKEN = $realToken
}
}

Expand Down Expand Up @@ -64,7 +65,7 @@ function Add-PropertiesToJsonFile {
)

if ($wait -and $commit) {
$headers = GetHeaders -token $token -repository "$($script:githubOwner)/.github"
$headers = GetHeaders -token $script:token -repository "$($script:githubOwner)/.github"
Write-Host "Get Previous runs"
$url = "https://api.github.com/repos/$repository/actions/runs"
$previousrunids = ((InvokeWebRequest -Method Get -Headers $headers -Uri $url -retry).Content | ConvertFrom-Json).workflow_runs | Where-Object { $_.event -eq 'push' } | Select-Object -ExpandProperty id
Expand Down Expand Up @@ -124,7 +125,7 @@ function Remove-PropertiesFromJsonFile {
}

function DisplayTokenAndRepository {
Write-Host "Token: $token"
Write-Host "Token: $($script:token)"
Write-Host "Repo: $defaultRepository"
}

Expand All @@ -146,7 +147,7 @@ function RunWorkflow {
Write-Host ($parameters | ConvertTo-Json)
}

$headers = GetHeaders -token $token -repository "$($script:githubOwner)/.github"
$headers = GetHeaders -token $script:token -repository "$($script:githubOwner)/.github"
WaitForRateLimit -headers $headers -displayStatus

Write-Host "Get Workflows"
Expand Down Expand Up @@ -211,7 +212,7 @@ function DownloadWorkflowLog {
if (!$repository) {
$repository = $defaultRepository
}
$headers = GetHeaders -token $token -repository "$($script:githubOwner)/.github"
$headers = GetHeaders -token $script:token -repository "$($script:githubOwner)/.github"
$url = "https://api.github.com/repos/$repository/actions/runs/$runid"
$run = ((InvokeWebRequest -Method Get -Headers $headers -Uri $url).Content | ConvertFrom-Json)
$log = InvokeWebRequest -Method Get -Headers $headers -Uri $run.logs_url
Expand Down Expand Up @@ -271,7 +272,7 @@ function WaitWorkflow {
$status = ""
do {
if ($count % 45 -eq 0) {
$headers = GetHeaders -token $token -repository "$($script:githubOwner)/.github"
$headers = GetHeaders -token $script:token -repository "$($script:githubOwner)/.github"
}
if ($delay) {
Start-Sleep -Seconds 60
Expand Down Expand Up @@ -490,8 +491,8 @@ function CreateAlGoRepository {
invoke-git add *
invoke-git commit --allow-empty -m 'init'
invoke-git branch -M $branch
if ($githubOwner -and $token) {
invoke-git remote set-url origin "https://$($githubOwner):$token@github.com/$repository.git"
if ($githubOwner -and $script:token) {
invoke-git remote set-url origin "https://$($githubOwner):$($script:token)@github.com/$repository.git"
}
invoke-git push --set-upstream origin $branch
if (!$github) {
Expand Down Expand Up @@ -530,7 +531,7 @@ function MergePRandPull {
}

Write-Host "Get Previous runs"
$headers = GetHeaders -token $token -repository "$($script:githubOwner)/.github"
$headers = GetHeaders -token $script:token -repository "$($script:githubOwner)/.github"
$url = "https://api.github.com/repos/$repository/actions/runs"
$previousrunids = ((InvokeWebRequest -Method Get -Headers $headers -Uri $url -retry).Content | ConvertFrom-Json).workflow_runs | Where-Object { $_.event -eq 'push' } | Select-Object -ExpandProperty id
if ($previousrunids) {
Expand Down

0 comments on commit cea8eda

Please sign in to comment.