Skip to content

Commit

Permalink
ci: mapping between conventional commits and labels is configured in …
Browse files Browse the repository at this point in the history
…a specific file (#601)

ci: mapping between conventional commits and labels is configured in specific file
  • Loading branch information
Seddryck authored Oct 29, 2023
1 parent ed39fe3 commit e680363
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
14 changes: 14 additions & 0 deletions .github/conventional_commits_labels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"!": "breaking-change",
"chore": "dependency-update",
"docs": "docs",
"style": "none",
"ci": "build",
"build": "build",
"feat": "new-feature",
"test": "none",
"refactor": "none",
"revert": "none",
"perf": "enhancement",
"fix": "bug"
}
4 changes: 4 additions & 0 deletions DubUrl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DubUrl.Testing", "DubUrl.Testing\DubUrl.Testing.csproj", "{A0CDC412-D16C-4508-96FC-6F0BB383E962}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C923A152-4091-48BE-A984-686FF5E4ACCC}"
ProjectSection(SolutionItems) = preProject
conventional_commits_labels.yml = conventional_commits_labels.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{95E83BA6-B535-4D56-B06A-D00249A4EF00}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
.github\conventional_commits_labels.json = .github\conventional_commits_labels.json
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
github.ps1 = github.ps1
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ before_build:
SecretToken = $env:github_access_token
}
$context.Id = $context | Get-Commit-Associated-Pull-Requests
$context | Set-Pull-Request-Expected-Labels
$context | Set-Pull-Request-Expected-Labels -Config '.github\conventional_commits_labels.json'
} else {
Write-Host 'Not a merge on main built on appveyor. Skipping mapping conventional commits and labels.'
}
Expand Down
36 changes: 21 additions & 15 deletions github.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,28 @@ function Set-Pull-Request-Expected-Labels {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, ValueFromPipeline = $true)]
[object] $context
[object] $context,
[string] $config
)

$mapping = @{}
$mapping.Add('!', 'breaking-change')
$mapping.Add('build', 'build')
$mapping.Add('ci', 'build')
$mapping.Add('chore', 'dependency-update')
$mapping.Add('docs', 'docs')
$mapping.Add('feat', 'new-feature')
$mapping.Add('fix', 'bug')
$mapping.Add('perf', 'enhancement')
$mapping.Add('refactor', 'none')
$mapping.Add('revert', 'none')
$mapping.Add('style', 'none')
$mapping.Add('test', 'none')
if ($config) {
WRite-Host "Reading mapping from $config"
$mapping = (Get-Content $config | ConvertFrom-Json)
} else {
$mapping = @{}
$mapping.Add('!', 'breaking-change')
$mapping.Add('build', 'build')
$mapping.Add('ci', 'build')
$mapping.Add('chore', 'dependency-update')
$mapping.Add('docs', 'docs')
$mapping.Add('feat', 'new-feature')
$mapping.Add('fix', 'bug')
$mapping.Add('perf', 'enhancement')
$mapping.Add('refactor', 'none')
$mapping.Add('revert', 'none')
$mapping.Add('style', 'none')
$mapping.Add('test', 'none')
}

$title = $context | Get-Pull-Request-Title
$existing = $context | Get-Pull-Request-Labels
Expand All @@ -226,4 +232,4 @@ function Set-Pull-Request-Expected-Labels {
} else {
Write-Host "Labels already up-to-date."
}
}
}

0 comments on commit e680363

Please sign in to comment.