-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathActionsHelp.cs
56 lines (48 loc) · 1.95 KB
/
ActionsHelp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using OctoClient.Models;
namespace OctoClient
{
public static class ActionsHelp
{
public static ActionResult<Inputs> ReadInputValues()
{
var inputResult = new ActionResult<Inputs>();
inputResult.Result = new Inputs
{
OctopusURL = Environment.GetEnvironmentVariable("INPUT_OCTOPUS_URL"),
OctopusApiKey = Environment.GetEnvironmentVariable("INPUT_API_KEY"),
ProjectName = Environment.GetEnvironmentVariable("INPUT_PROJECT_NAME"),
ReleaseId = Environment.GetEnvironmentVariable("INPUT_RELEASE_ID"),
EnvironmentName = Environment.GetEnvironmentVariable("INPUT_ENVIRONMENT_NAME"),
ChannelName = Environment.GetEnvironmentVariable("INPUT_CHANNEL_NAME")
};
var version = Environment.GetEnvironmentVariable("INPUT_RELEASE_VERSION");
if (!string.IsNullOrWhiteSpace(version))
{
inputResult.Result.ReleaseVersion = version.Replace("refs/tags/", "");
}
var space = Environment.GetEnvironmentVariable("INPUT_SPACE_NAME");
if (!string.IsNullOrWhiteSpace(space))
{
inputResult.Result.SpaceName = space;
}
inputResult.Error = inputResult.Result.ValidateCommonInputs();
return inputResult;
}
public static void WriteOutput(OctoRelease release)
{
Console.WriteLine($"::set-output name=release_id::{release.ID}");
}
public static void WriteOutput(OctoDeployment deployment)
{
Console.WriteLine($"::set-output name=deployment_id::{deployment.ID}");
}
public static void WriteOutput(OctoClientErrors errors)
{
foreach (var err in errors.ErrorMessages)
{
Console.WriteLine($"::error:: {err}");
}
}
}
}