Class GithubExpressionPrinter
- Namespace
- Invex.StructuredText.GithubActions
- Assembly
- Invex.StructuredText.GithubActions.dll
Renders typed expressions (Expr) and Templates to GitHub Actions expression
syntax: infix operators (==, &&, !), single-quoted string literals, and
${{ … }} around expressions embedded in text.
public sealed class GithubExpressionPrinter : ExpressionPrinter
- Inheritance
-
objectGithubExpressionPrinter
- Inherited Members
Remarks
Portable references render as context paths: secrets as secrets.NAME, variables as vars.NAME,
inputs as inputs.NAME, matrix values as matrix.NAME, job outputs as
needs.JOB.outputs.NAME, step outputs as steps.STEP.outputs.NAME and job results as
needs.JOB.result. Result literals render as 'success', 'failure', 'cancelled' and
'skipped'.
Constructors
GithubExpressionPrinter()
public GithubExpressionPrinter()
Properties
Instance
A shared instance. The printer is stateless.
public static GithubExpressionPrinter Instance { get; }
Property Value
Methods
FunctionName(string)
Maps a canonical function name (see FunctionNames) to the platform's name. Returns the name unchanged by default.
protected override string FunctionName(string name)
Parameters
namestringThe canonical name.
Returns
- string
The platform's name.
Remarks
GitHub's contains covers both substring and array membership tests.
PrintCondition(BoolExpr?)
Renders an if: condition. The bare expression is used where possible; a condition whose first
non-whitespace character means something to YAML (! starts a tag, a quote starts a quoted scalar,
and so on) is wrapped in ${{ }}.
public string? PrintCondition(BoolExpr? condition)
Parameters
conditionBoolExprThe condition.
Returns
PrintReference(ReferenceExpr)
Renders a portable reference such as a secret or a job output.
protected override string PrintReference(ReferenceExpr reference)
Parameters
referenceReferenceExprThe reference.
Returns
- string
The rendered text.
PrintResult(RunResult)
Renders a run result literal.
protected override string PrintResult(RunResult result)
Parameters
resultRunResultThe result.
Returns
- string
The rendered text.
StartsWithYamlIndicator(string)
true when text, after leading whitespace, starts with a character
that YAML would not read as the start of a plain scalar.
public static bool StartsWithYamlIndicator(string text)
Parameters
textstringThe text to test.
Returns
- bool
Whether the text needs quoting or wrapping before it can be written as a YAML value.
WrapEmbedded(string)
Wraps a rendered expression that is embedded in literal text, e.g. in expression delimiters.
protected override string WrapEmbedded(string printedExpression)
Parameters
printedExpressionstringThe rendered expression.
Returns
- string
The wrapped text.