mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
fix.修复 PR 时 CI 爆炸的问题
GitHub 你罪大恶极!(划掉) 我是笨比(
This commit is contained in:
@@ -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("==========================");
|
||||
|
||||
@@ -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<string, string> 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");
|
||||
|
||||
Reference in New Issue
Block a user