Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- name: Check out
uses: actions/checkout@v3
- name: Setup .Net
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.100
dotnet-version: 10.x
- name: Restore
run: dotnet restore
- name: Build
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
- name: Check out
uses: actions/checkout@v3
- name: Setup .Net
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x
- name: Restore
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/prLinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,41 @@ jobs:
permissions:
contents: read
pull-requests: read
setAuthorAsPrAssignee:
name: Set Author As PR Assignee
runs-on: ubuntu-latest
steps:
- name: Set Author As PR Assignee
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: >
const pr = context.payload.pull_request;

if (!pr) {
console.log('No pull request context available.');
return;
}


const author = pr.user.login;

if (author.endsWith('[bot]')) {
console.log(`Skipping bot author: ${author}`);
return;
}


console.log(`Assigning PR to author: ${author}`);


await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
assignees: [author]
});
permissions:
contents: read
issues: write
pull-requests: write
17 changes: 12 additions & 5 deletions ADotNet.Infrastructure.Build/Services/ScriptGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using ADotNet.Clients;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV4s;

namespace ADotNet.Infrastructure.Build.Services
{
Expand Down Expand Up @@ -53,11 +53,11 @@ public void GenerateBuildScript(string branchName, string projectName, string do
Name = "Check out"
},

new SetupDotNetTaskV3
new SetupDotNetTaskV4
{
Name = "Setup .Net",

With = new TargetDotNetVersionV3
With = new TargetDotNetVersionV4
{
DotNetVersion = dotNetVersion
}
Expand All @@ -82,7 +82,7 @@ public void GenerateBuildScript(string branchName, string projectName, string do
},
{
"add_tag",
new TagJob(
new TagJobV1(
runsOn: BuildMachines.UbuntuLatest,
dependsOn: "build",
projectRelativePath: "ADotNet/ADotNet.csproj",
Expand All @@ -94,7 +94,7 @@ public void GenerateBuildScript(string branchName, string projectName, string do
},
{
"publish",
new PublishJobV2(
new PublishJobV3(
runsOn: BuildMachines.UbuntuLatest,
dependsOn: "add_tag",
dotNetVersion: dotNetVersion,
Expand Down Expand Up @@ -150,6 +150,13 @@ public void GeneratePrLintScript(string branchName)
Name = "Require Issue Or Task Association",
}
},
{
"setAuthorAsPrAssignee",
new SetAuthorAsPrAssigneeJob(runsOn: BuildMachines.UbuntuLatest)
{
Name = "Set Author As PR Assignee",
}
}
}
};

Expand Down
102 changes: 102 additions & 0 deletions ADotNet/Models/Pipelines/GithubPipelines/DotNets/PublishJobV3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

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

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
public class PublishJobV3 : Job
{
public PublishJobV3(
string runsOn,
string dependsOn,
string dotNetVersion,
string nugetApiKey)
{
RunsOn = runsOn;
Needs = new string[] { dependsOn };

If = $"needs.{dependsOn}.result == 'success'";

Steps = new List<GithubTask> {
new CheckoutTaskV3
{
Name = "Check out"
},

new SetupDotNetTaskV4
{
Name = "Setup .Net",

With = new TargetDotNetVersionV4
{
DotNetVersion = dotNetVersion
}
},

new RestoreTask
{
Name = "Restore"
},

new DotNetBuildReleaseTask
{
Name = "Build",
},

new PackNugetTaskWithSymbols
{
Name = "Pack NuGet Package",
},

new NugetPushTask(nugetApiKey)
{
Name = "Push NuGet Package",
}
};

}

[YamlMember(Order = 0, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string Name { get; set; }

[YamlMember(Order = 1, Alias = "runs-on")]
public new string RunsOn { get; set; }

[YamlMember(Order = 2, Alias = "needs", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string[] Needs { get; set; }

[YamlMember(Order = 3, Alias = "if", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string If { get; set; }

[YamlMember(Order = 4, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string Environment { get; set; }

[YamlMember(Order = 5, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new DefaultValues Defaults { get; set; }

[YamlMember(Order = 6)]
public new List<GithubTask> Steps { get; set; }

[DefaultValue(0)]
[YamlMember(Order = 7, Alias = "timeout-minutes", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new int TimeoutInMinutes { get; set; }

[YamlMember(Order = 8, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Strategy Strategy { get; set; }

[YamlMember(Order = 9, Alias = "env", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> EnvironmentVariables { get; set; }

[YamlMember(Order = 10, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> Outputs { get; set; }
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

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

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
public sealed class SetAuthorAsPrAssigneeJob : Job
{
public SetAuthorAsPrAssigneeJob(string runsOn)
{
RunsOn = runsOn;

Permissions = new Dictionary<string, string>
{
{ "contents", "read" },
{ "issues", "write" },
{ "pull-requests", "write" }
};

Steps = new List<GithubTask>
{
new GithubTask()
{
Name = "Set Author As PR Assignee",
Uses = "actions/github-script@v6",
With = new Dictionary<string, string>
{
{ "github-token", "${{ secrets.GITHUB_TOKEN }}" },
{ "script",
"const pr = context.payload.pull_request;\n" +
"if (!pr) {\n" +
" console.log('No pull request context available.');\n" +
" return;\n" +
"}\n\n" +
"const author = pr.user.login;\n" +
"if (author.endsWith('[bot]')) {\n" +
" console.log(`Skipping bot author: ${author}`);\n" +
" return;\n" +
"}\n\n" +
"console.log(`Assigning PR to author: ${author}`);\n\n" +
"await github.rest.issues.addAssignees({\n" +
" owner: context.repo.owner,\n" +
" repo: context.repo.repo,\n" +
" issue_number: pr.number,\n" +
" assignees: [author]\n" +
"});\n"
}
}
},
};
}

[YamlMember(Order = 0, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string Name { get; set; }

[YamlMember(Order = 1, Alias = "runs-on")]
public new string RunsOn { get; set; }

[YamlMember(Order = 2, Alias = "needs", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string[] Needs { get; set; }

[YamlMember(Order = 3, Alias = "if", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string If { get; set; }

[YamlMember(Order = 4, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string Environment { get; set; }

[YamlMember(Order = 5, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new DefaultValues Defaults { get; set; }

[YamlMember(Order = 6)]
public new List<GithubTask> Steps { get; set; }

[DefaultValue(0)]
[YamlMember(Order = 7, Alias = "timeout-minutes", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new int TimeoutInMinutes { get; set; }

[YamlMember(Order = 8, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Strategy Strategy { get; set; }

[YamlMember(Order = 9, Alias = "env", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> EnvironmentVariables { get; set; }

[YamlMember(Order = 10, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> Outputs { get; set; }

[DefaultValue(false)]
[YamlMember(Order = 11, Alias = "continue-on-error", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new bool ContinueOnError { get; set; }

[YamlMember(Order = 12, Alias = "permissions", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> Permissions { get; set; }
}
}
Loading
Loading