-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9059 from Azure/arm-ttk-slash-command
Arm-ttk slash command and customization
- Loading branch information
Showing
3 changed files
with
104 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# THIS WORKFLOW WILL RUN WHEN WE ADD SLASH COMMAND LIKE '/arm-ttk', '/ARM-TTK', '/Arm-Ttk', 'armttk' or 'ARMTTK' | ||
name: Slash Command ARM-TTK Tests | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
jobs: | ||
run-arm-ttk: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && github.event.issue.pull_request && contains(fromJson('["/armttk", "/Armttk", "/ARM-TTK", "/ARMTTK", "/arm-ttk", "/ArmTtk"]'), github.event.comment.body) }} | ||
outputs: | ||
solutionName: ${{ steps.step1.outputs.solutionName }} | ||
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }} | ||
createUiChanged: ${{ steps.step1.outputs.createUiChanged }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 5 | ||
ref: refs/pull/${{ github.event.issue.number }}/head | ||
- shell: pwsh | ||
id: step1 | ||
name: Identify Changes in PR | ||
run: | | ||
Set-PSRepository PSGallery -InstallationPolicy Trusted | ||
Install-Module powershell-yaml | ||
./.script/package-automation/arm-ttk-tests.ps1 | ||
- uses: docker/build-push-action@v2 | ||
id: publishGithubPackage | ||
name: Run ARM-TTK | ||
if: ${{ success() && steps.step1.outcome == 'success' && steps.step1.outputs.solutionName != '' && (steps.step1.outputs.mainTemplateChanged == 'true' || steps.step1.outputs.createUiChanged == 'true') }} | ||
env: | ||
SolutionName: ${{ steps.step1.outputs.solutionName }} | ||
mainTemplateChanged: ${{ steps.step1.outputs.mainTemplateChanged }} | ||
createUiChanged: ${{ steps.step1.outputs.createUiChanged }} | ||
with: | ||
context: . | ||
file: ./.github/actions/Dockerfile | ||
push: false | ||
build-args: | | ||
SolutionName | ||
mainTemplateChanged | ||
createUiChanged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
try { | ||
$diff = git diff --diff-filter=d --name-only HEAD^ HEAD | ||
Write-Host "List of files in PR: $diff" | ||
|
||
$hasmainTemplateChanged = $false | ||
$hasCreateUiDefinitionTemplateChanged = $false | ||
|
||
$isChangeInSolutionsFolder = [bool]($diff | Where-Object {$_ -like 'Solutions/*'}) | ||
if (!$isChangeInSolutionsFolder) | ||
{ | ||
Write-Host "Skipping as change is not in Solutions folder!" | ||
exit 0 | ||
} | ||
|
||
$requiredFiles = @("mainTemplate.json", "createUiDefinition.json") | ||
$filteredFiles = $diff | Where-Object {$_ -match ($requiredFiles -Join "|")} | ||
Write-Host "Filtered Files $filteredFiles" | ||
|
||
$sName = '' | ||
$hasmainTemplateChanged = $false | ||
$hasCreateUiDefinitionTemplateChanged = $false | ||
|
||
if ($filteredFiles.Count -gt 0) | ||
{ | ||
$mainTemplateValue = $filteredFiles -match "mainTemplate.json" | ||
$createUiValue = $filteredFiles -match "createUiDefinition.json" | ||
|
||
if ($mainTemplateValue -or $createUiValue) | ||
{ | ||
$hasmainTemplateChanged = $true | ||
$hasCreateUiDefinitionTemplateChanged = $true | ||
} | ||
|
||
if ($filteredFiles.Count -eq 1) | ||
{ | ||
$packageIndex = $filteredFiles.IndexOf("/Package") | ||
$sName = $filteredFiles.SubString(10, $packageIndex - 10) | ||
} | ||
else | ||
{ | ||
$packageIndex = $filteredFiles[0].IndexOf("/Package") | ||
$sName = $filteredFiles[0].SubString(10, $packageIndex - 10) | ||
} | ||
} | ||
|
||
Write-Host "solutionName $sName, mainTemplateChanged $hasmainTemplateChanged, createUiChanged $hasCreateUiDefinitionTemplateChanged" | ||
Write-Output "solutionName=$sName" >> $env:GITHUB_OUTPUT | ||
Write-Output "mainTemplateChanged=$hasmainTemplateChanged" >> $env:GITHUB_OUTPUT | ||
Write-Output "createUiChanged=$hasCreateUiDefinitionTemplateChanged" >> $env:GITHUB_OUTPUT | ||
} | ||
catch { | ||
Write-Host "Skipping as exception has occured Error Details: $_" | ||
Write-Output "solutionName=''" >> $env:GITHUB_OUTPUT | ||
Write-Output "mainTemplateChanged=$false" >> $env:GITHUB_OUTPUT | ||
Write-Output "createUiChanged=$false" >> $env:GITHUB_OUTPUT | ||
} |