Skip to content

Commit

Permalink
only work on self-hosted jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Apr 11, 2024
1 parent d51e536 commit c189280
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,35 @@ public static void Main(string[] args)
logger.LogWarning("Received a non-workflowJob request. Ignoring.");
return;
}
List<string?> labels = workflowJson.GetProperty("labels").EnumerateArray()
.Select(x => x.GetString()).ToList();
if (!labels.Contains("self-hosted"))
{
logger.LogInformation("Received a non self-hosted request. Ignoring.");
return;
}
long jobId = workflowJson.GetProperty("id").GetInt64();
string repoName = json.RootElement.GetProperty("repository").GetProperty("full_name").GetString();
string orgName = json.RootElement.GetProperty("organization").GetProperty("login").GetString();
// Check if Org is configured
if (Config.OrgConfigs.All(x => x.OrgName != orgName))
{
logger.LogWarning($"GitHub Org {orgName} is not configured. Ignoring.");
return;
}
switch (action)
{
case "queued":
logger.LogInformation($"New Workflow Job was queued for {repoName}. Creating VM to replenish pool...");
List<string?> labels = workflowJson.GetProperty("labels").EnumerateArray()
.Select(x => x.GetString()).ToList();
string size = "size-xs"; // Tiny if not specified - 1C/2G
string size = string.Empty;
foreach (string csize in Config.Sizes.Where(x => x.Arch == "x64").Select(x => x.Name))
{
if (labels.Contains(csize))
Expand All @@ -144,6 +159,12 @@ public static void Main(string[] args)
break;
}
}
if (string.IsNullOrEmpty(size))
{
logger.LogWarning($"No runner size specified for workflow in {repoName}. Ignoring.");
return;
}
// Create a new runner
string? githubToken = Config.OrgConfigs.FirstOrDefault(x => x.OrgName == orgName)?.GitHubToken;
Expand Down

0 comments on commit c189280

Please sign in to comment.