commit d504950f92eb9a2de161c4d8375df5f5c195395e Author: achi Date: Wed Oct 23 22:09:19 2024 +1000 Initial commit diff --git a/Handle-PullRequestComment.ps1 b/Handle-PullRequestComment.ps1 new file mode 100644 index 0000000..d06132a --- /dev/null +++ b/Handle-PullRequestComment.ps1 @@ -0,0 +1,29 @@ +param( + [Parameter(Mandatory=$true)] [string] $teamCityToken, + [Parameter(Mandatory=$true)] [string] $giteaToken, + [Parameter(Mandatory=$true)] [string] $branch, + [Parameter(Mandatory=$true)] [string] $pullId +) + +Write-Output "Starting tests in $branch" + +$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent + + +& $scriptDir/Run-TeamCityBuild.ps1 -token $teamCityToken -branch $branch -buildId "LU_FullTests" +& $scriptDir/Run-TeamCityBuild.ps1 -token $teamCityToken -branch $branch -buildId "LU_ReleaseBuild" + +# Получим теги пулл-реквеста + +Invoke-RestMethod -Uri https://sc.lers.ru/api/v1/repos/lers/LersUchet/pulls/$pullId -Headers @{Authorization = "token $giteaToken"} + +Write-Output $pull.labels +Write-Output "checking wb" + +$webLabel = $pull.labels | Where-Object { $_.name -eq "comp/Web" } + +if ($webLabel) +{ + Write-Host "Running web tests" + & $scriptDir/Run-TeamCityBuild.ps1 -token $teamCityToken -branch $branch -buildId "LU_Tests_WebTests" +} diff --git a/Run-TeamcityBuild.ps1 b/Run-TeamcityBuild.ps1 new file mode 100644 index 0000000..e0f37ad --- /dev/null +++ b/Run-TeamcityBuild.ps1 @@ -0,0 +1,16 @@ +param( + [Parameter(Mandatory=$true)] [string] $token, + [Parameter(Mandatory=$true)] [string] $branch, + [Parameter(Mandatory=$true)] [string] $buildId +) + +$tcUrl = "https://build.lers.ru" + +$params=@{ + branchName = $branch + buildType = @{ + id = $buildId + } +} + +Invoke-RestMethod $tcUrl/app/rest/buildQueue -Headers @{Authorization = "Bearer $token"} -Method 'POST' -ContentType 'application/json' -Body ($params|ConvertTo-Json) diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..498f589 --- /dev/null +++ b/action.yml @@ -0,0 +1,23 @@ +name: Run Teamcity tests +description: Run teamcity tests + +inputs: + teamcity-token: + description: 'Teamcity token' + required: true + gitea-token: + description: 'Gitea token token' + required: true + branch: + description: 'Branch to test' + required: true + pull-id: + description: 'Pull request id' + required: true + +runs: + using: "composite" + steps: + - name: Start Teamcity tests + shell: powershell + run: ${{ gitea.action_path }}/Handle-PullRequestComment.ps1 -teamCityToken ${{ inputs.teamcity-token }} -giteaToken ${{ inputs.gitea-token }} -branch ${{ inputs.branch }} -pullId ${{ inputs.pull-id }}