Skip to content

Commit

Permalink
Set env vars in GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Jan 15, 2020
1 parent bdd0db3 commit 054cb7f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/NerdBank.GitVersioning/CloudBuildServices/GitHubActions.cs
Expand Up @@ -26,7 +26,18 @@ internal class GitHubActions : ICloudBuild

public IReadOnlyDictionary<string, string> SetCloudBuildVariable(string name, string value, TextWriter stdout, TextWriter stderr)
{
return new Dictionary<string, string>();
(stdout ?? Console.Out).WriteLine($"##[set-env name={name};]{value}");
return GetDictionaryFor(name, value);
}

private static IReadOnlyDictionary<string, string> GetDictionaryFor(string variableName, string value)
{
return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ GetEnvironmentVariableNameForVariable(variableName), value },
};
}

private static string GetEnvironmentVariableNameForVariable(string name) => name.ToUpperInvariant().Replace('.', '_');
}
}

0 comments on commit 054cb7f

Please sign in to comment.