forked from Azure/bicep-registry-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add additional logic if workflow fails and issue is created (Az…
…ure#1403) More fine grained logic, regarding commenting and assigning new failing workflow issues
- Loading branch information
Showing
5 changed files
with
188 additions
and
11 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
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
57 changes: 57 additions & 0 deletions
57
avm/utilities/pipelines/platform/helper/Add-GithubIssueToProject.ps1
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 @@ | ||
<# | ||
.SYNOPSIS | ||
Adds an existing GitHub issue to an existing GitHub project (the new type, not the classic ones) | ||
.DESCRIPTION | ||
Adds an existing GitHub issue to an existing GitHub project (the new type, not the classic ones) | ||
.PARAMETER Repo | ||
Mandatory. The name of the respository to scan. Needs to have the structure "<owner>/<repositioryName>", like 'Azure/bicep-registry-modules/' | ||
.PARAMETER ProjectNumber | ||
Mandatory. The GitHub project number (see last part of project URL, for example 538 for https://github.com/orgs/Azure/projects/538) | ||
.PARAMETER IssueUrl | ||
Mandatory. The URL of the GitHub issue, like 'https://github.com/Azure/bicep-registry-modules/issues/757' | ||
.EXAMPLE | ||
Add-GithubIssueToProject -Repo 'Azure/bicep-registry-modules' -ProjectNumber 538 -IssueUrl 'https://github.com/Azure/bicep-registry-modules/issues/757' | ||
.NOTES | ||
Needs to run under a context with the permissions to read/write organization projects | ||
#> | ||
function Add-GithubIssueToProject { | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $Repo, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[int] $ProjectNumber, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] $IssueUrl | ||
) | ||
|
||
$Organization = $Repo.Split('/')[0] | ||
|
||
$Project = gh api graphql -f query=' | ||
query($organization: String! $number: Int!){ | ||
organization(login: $organization){ | ||
projectV2(number: $number) { | ||
id | ||
} | ||
} | ||
}' -f organization=$Organization -F number=$ProjectNumber | ConvertFrom-Json -Depth 10 | ||
|
||
$ProjectId = $Project.data.organization.projectV2.id | ||
$IssueId = (gh issue view $IssueUrl --repo $Repo --json 'id' | ConvertFrom-Json -Depth 100).id | ||
|
||
gh api graphql -f query=' | ||
mutation($project:ID!, $issue:ID!) { | ||
addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) { | ||
item { | ||
id | ||
} | ||
} | ||
}' -f project=$ProjectId -f issue=$IssueId | ||
} |
59 changes: 59 additions & 0 deletions
59
avm/utilities/pipelines/platform/helper/Get-AvmCsvData.ps1
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,59 @@ | ||
<# | ||
.SYNOPSIS | ||
Parses AVM module CSV file | ||
.DESCRIPTION | ||
Depending on the parameter, the correct CSV file will be parsed and returned a an object | ||
.PARAMETER ModuleIndex | ||
Mandatory. Type of CSV file, that should be parsed ('Bicep-Resource', 'Bicep-Pattern') | ||
.EXAMPLE | ||
Get-AvmCsvData -ModuleIndex 'Bicep-Resource' | ||
Parse the AVM Bicep modules | ||
#> | ||
Function Get-AvmCsvData { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory)] | ||
[ValidateSet('Bicep-Resource', 'Bicep-Pattern')] | ||
[string] $ModuleIndex | ||
) | ||
|
||
# CSV file URLs | ||
$BicepResourceUrl = 'https://aka.ms/avm/index/bicep/res/csv' | ||
$BicepPatternUrl = 'https://aka.ms/avm/index/bicep/ptn/csv' | ||
|
||
# Retrieve the CSV file | ||
switch ($ModuleIndex) { | ||
'Bicep-Resource' { | ||
try { | ||
$unfilteredCSV = Invoke-WebRequest -Uri $BicepResourceUrl | ||
} catch { | ||
throw 'Unable to retrieve CSV file - Check network connection.' | ||
} | ||
} | ||
'Bicep-Pattern' { | ||
try { | ||
$unfilteredCSV = Invoke-WebRequest -Uri $BicepPatternUrl | ||
} catch { | ||
throw 'Unable to retrieve CSV file - Check network connection.' | ||
} | ||
} | ||
} | ||
|
||
# Convert the CSV content to a PowerShell object | ||
$formattedBicepFullCsv = ConvertFrom-Csv $unfilteredCSV.Content | ||
|
||
# Loop through each item in the filtered data | ||
foreach ($item in $formattedBicepFullCsv) { | ||
# Remove '@Azure/' from the ModuleOwnersGHTeam property | ||
$item.ModuleOwnersGHTeam = $item.ModuleOwnersGHTeam -replace '@Azure\/', '' | ||
# Remove '@Azure/' from the ModuleContributorsGHTeam property | ||
$item.ModuleContributorsGHTeam = $item.ModuleContributorsGHTeam -replace '@Azure\/', '' | ||
} | ||
|
||
# Return the modified data | ||
return $formattedBicepFullCsv | ||
} |