diff --git a/src/MeoAssistantBuilder/Build.cs b/src/MeoAssistantBuilder/Build.cs index c1bf354110..3a56ad39c2 100644 --- a/src/MeoAssistantBuilder/Build.cs +++ b/src/MeoAssistantBuilder/Build.cs @@ -86,11 +86,15 @@ public partial class Build : NukeBuild Information("5. 配置"); Information($"构建时间:{Parameters.BuildTime ?? "Null"}"); Information($"Commit Hash:{Parameters.CommitHash ?? "Null"}"); + Information($"Commit Hash Full:{Parameters.CommitHashFull ?? "Null"}"); Information("6. CI"); Information($"在 GitHub Actions 中运行:{Parameters.IsGitHubActions}"); + Information($"是 Pull Request:{Parameters.IsPullRequest}"); + Information($"是 Workflow Dispatch 触发:{Parameters.IsWorkflowDispatch}"); Information($"Actions 名称:{Parameters.GhActionName ?? "Null"}"); Information($"Actions 分支:{Parameters.GhBranch ?? "Null"}"); + Information($"Actions PR:{Parameters.GhPullRequestId ?? "Null"}"); Information($"Actions Tag:{Parameters.GhTag ?? "Null"}"); Information("=========================="); diff --git a/src/MeoAssistantBuilder/BuildParameters.cs b/src/MeoAssistantBuilder/BuildParameters.cs index 124502a96a..3330c60d42 100644 --- a/src/MeoAssistantBuilder/BuildParameters.cs +++ b/src/MeoAssistantBuilder/BuildParameters.cs @@ -83,11 +83,13 @@ public partial class Build // CI public bool IsGitHubActions { get; } + public bool IsPullRequest { get; } public bool IsWorkflowDispatch { get; } public string GitHubPersonalAccessToken { get; } = null; public Dictionary WorkflowDispatchArguments { get; } public ActionConfiguration GhActionName { get; } = null; public string GhBranch { get; } = null; + public string GhPullRequestId { get; } = null; public string GhTag { get; } = null; public BuildParameters(Build b) @@ -108,6 +110,7 @@ public partial class Build MasterBranchRef = "refs/heads/master"; DevBranchRef = "refs/heads/dev"; ReleaseTagRefPrefix = "refs/tags/v"; + // 路径 BuildOutput = RootDirectory / "x64"; @@ -158,6 +161,11 @@ public partial class Build { GhBranch = b.GitHubActions.Ref.Replace("refs/heads/", ""); } + else if (b.GitHubActions.Ref.StartsWith("refs/pull")) + { + IsPullRequest = true; + GhPullRequestId = b.GitHubActions.Ref.Replace("refs/pull/", ""); + } else { Assert.Fail($"不支持的 Ref:{b.GitHubActions.Ref}"); @@ -186,13 +194,17 @@ public partial class Build IsFork = true; } - // 若是 DevBuild,Branch 必须为 Dev,又或者是手动触发 + // 若是 DevBuild,Branch 必须为 Dev,或者是 PR,又或者是手动触发 if (GhActionName == ActionConfiguration.DevBuild) { if (IsWorkflowDispatch) { Assert.True(GhBranch is not null, "DevBuild -> Workflow Dispatch,Branch 为 Null"); } + else if (IsPullRequest) + { + Assert.True(GhPullRequestId is not null, "DevBuild -> Pull Request,Pull Request Id 为 Null"); + } else { Assert.True(GhBranch == DevBranch, "DevBuild -> Auto Triggered,Branch 不为 dev");