Skip to content

Commit

Permalink
CODE RUB: Fixed formatting issues and regenerated the build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdutoit committed Nov 25, 2024
1 parent 114521b commit ecb2306
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 68 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ jobs:
- name: Apply Label
uses: actions/github-script@v6
with:
github-token: ${{ secrets.PAT_FOR_TAGGING }}
script: >2+
github-token: ${{ secrets.GITHUB_TOKEN }}
script: >-
const prefixes = [
'INFRA:',
'PROVISIONS:',
Expand Down Expand Up @@ -99,6 +98,9 @@ jobs:
break;
}
}
permissions:
contents: read
pull-requests: write
build:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 1 addition & 3 deletions ADotNet.Infrastructure.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ static void Main(string[] args)
{
{
"label",
new LabelJob(
runsOn: BuildMachines.UbuntuLatest,
githubToken: "${{ secrets.PAT_FOR_TAGGING }}")
new LabelJobV2(runsOn: BuildMachines.UbuntuLatest)
},
{
"build",
Expand Down
1 change: 1 addition & 0 deletions ADotNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{16CB1804-3040-41F0-9C1F-99A139B24873}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
Global
Expand Down
2 changes: 2 additions & 0 deletions ADotNet/Models/Pipelines/GithubPipelines/DotNets/LabelJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
using YamlDotNet.Serialization;

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
[Obsolete("This job is now obsolete. Please migrate to LabelJobV2.")]
public sealed class LabelJob : Job
{
public LabelJob(
Expand Down
123 changes: 62 additions & 61 deletions ADotNet/Models/Pipelines/GithubPipelines/DotNets/LabelJobV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,69 +32,70 @@ public LabelJobV2(string runsOn)
With = new Dictionary<string, string>
{
{ "github-token", "${{ secrets.GITHUB_TOKEN }}" },
{ "script", @"
const prefixes = [
'INFRA:',
'PROVISIONS:',
'RELEASES:',
'DATA:',
'BROKERS:',
'FOUNDATIONS:',
'PROCESSINGS:',
'ORCHESTRATIONS:',
'COORDINATIONS:',
'MANAGEMENTS:',
'AGGREGATIONS:',
'CONTROLLERS:',
'CLIENTS:',
'EXPOSERS:',
'PROVIDERS:',
'BASE:',
'COMPONENTS:',
'VIEWS:',
'PAGES:',
'ACCEPTANCE:',
'INTEGRATIONS:',
'CODE RUB:',
'MINOR FIX:',
'MEDIUM FIX:',
'MAJOR FIX:',
'DOCUMENTATION:',
'CONFIG:',
'STANDARD:',
'DESIGN:',
'BUSINESS:'
];
const pullRequest = context.payload.pull_request;
if (!pullRequest) {
console.log('No pull request context available.');
return;
}
const title = context.payload.pull_request.title;
const existingLabels = context.payload.pull_request.labels.map(label => label.name);
for (const prefix of prefixes) {
if (title.startsWith(prefix)) {
const label = prefix.slice(0, -1);
if (!existingLabels.includes(label)) {
console.log(`Applying label: ${label}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: [label]
});
}
break;
}
}
" }
{ "script", """
const prefixes = [
'INFRA:',
'PROVISIONS:',
'RELEASES:',
'DATA:',
'BROKERS:',
'FOUNDATIONS:',
'PROCESSINGS:',
'ORCHESTRATIONS:',
'COORDINATIONS:',
'MANAGEMENTS:',
'AGGREGATIONS:',
'CONTROLLERS:',
'CLIENTS:',
'EXPOSERS:',
'PROVIDERS:',
'BASE:',
'COMPONENTS:',
'VIEWS:',
'PAGES:',
'ACCEPTANCE:',
'INTEGRATIONS:',
'CODE RUB:',
'MINOR FIX:',
'MEDIUM FIX:',
'MAJOR FIX:',
'DOCUMENTATION:',
'CONFIG:',
'STANDARD:',
'DESIGN:',
'BUSINESS:'
];
const pullRequest = context.payload.pull_request;
if (!pullRequest) {
console.log('No pull request context available.');
return;
}
const title = context.payload.pull_request.title;
const existingLabels = context.payload.pull_request.labels.map(label => label.name);
for (const prefix of prefixes) {
if (title.startsWith(prefix)) {
const label = prefix.slice(0, -1);
if (!existingLabels.includes(label)) {
console.log(`Applying label: ${label}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: [label]
});
}
break;
}
}
"""
}
}
},
};
};
}

[YamlMember(Order = 0, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV1s;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s;
using YamlDotNet.Serialization;

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
public class PublishJob : Job
{
[Obsolete("This job is now obsolete. Please migrate to PublishJobV2.")]
public PublishJob(
string runsOn,
string dependsOn,
Expand Down

0 comments on commit ecb2306

Please sign in to comment.