Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODE RUB: Fixed formatting issues and regenerated the build.yml #125

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
{
{
"label",
new LabelJob(
runsOn: BuildMachines.UbuntuLatest,
githubToken: "${{ secrets.PAT_FOR_TAGGING }}")
new LabelJobV2(runsOn: BuildMachines.UbuntuLatest)
},
{
"build",
Expand Down Expand Up @@ -102,7 +100,7 @@
},
{
"publish",
new PublishJob(

Check warning on line 103 in ADotNet.Infrastructure.Build/Program.cs

View workflow job for this annotation

GitHub Actions / build

'PublishJob.PublishJob(string, string, string)' is obsolete: 'This job is now obsolete. Please migrate to PublishJobV2.'

Check warning on line 103 in ADotNet.Infrastructure.Build/Program.cs

View workflow job for this annotation

GitHub Actions / build

'PublishJob.PublishJob(string, string, string)' is obsolete: 'This job is now obsolete. Please migrate to PublishJobV2.'
runsOn: BuildMachines.UbuntuLatest,
dependsOn: "add_tag",
nugetApiKey: "${{ secrets.NUGET_ACCESS }}")
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
Loading