io.github.cdklabs.projen.github.workflows.Step Maven / Gradle / Ivy
Show all versions of projen Show documentation
package io.github.cdklabs.projen.github.workflows;
/**
* (experimental) This contains the fields that are common amongst both: - JobStep, which is a step that is part of a Job in Github Actions.
*
* This is by far the most common use case.
*
*
* - The metadata file
action.yaml
that is used to define an Action when you are creating one. As in, if you were creating an Action to be used in a JobStep.
* There is some overlap between the two, and this captures that overlap.
*
*
* @see https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.105.0 (build 0a2adcb)", date = "2024-11-15T17:03:55.229Z")
@software.amazon.jsii.Jsii(module = io.github.cdklabs.projen.$Module.class, fqn = "projen.github.workflows.Step")
@software.amazon.jsii.Jsii.Proxy(Step.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface Step extends software.amazon.jsii.JsiiSerializable, io.github.cdklabs.projen.github.workflows.StepConfiguration {
/**
* (experimental) Runs command-line programs using the operating system's shell.
*
* If you do
* not provide a name, the step name will default to the text specified in
* the run command.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getRun() {
return null;
}
/**
* (experimental) Selects an action to run as part of a step in your job.
*
* An action is a
* reusable unit of code. You can use an action defined in the same
* repository as the workflow, a public repository, or in a published Docker
* container image.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getUses() {
return null;
}
/**
* (experimental) A map of the input parameters defined by the action.
*
* Each input parameter
* is a key/value pair. Input parameters are set as environment variables.
* The variable is prefixed with INPUT_ and converted to upper case.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.Map getWith() {
return null;
}
/**
* @return a {@link Builder} of {@link Step}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link Step}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.String run;
java.lang.String uses;
java.util.Map with;
java.util.Map env;
java.lang.String id;
java.lang.String ifValue;
java.lang.String name;
java.lang.String workingDirectory;
/**
* Sets the value of {@link Step#getRun}
* @param run Runs command-line programs using the operating system's shell.
* If you do
* not provide a name, the step name will default to the text specified in
* the run command.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder run(java.lang.String run) {
this.run = run;
return this;
}
/**
* Sets the value of {@link Step#getUses}
* @param uses Selects an action to run as part of a step in your job.
* An action is a
* reusable unit of code. You can use an action defined in the same
* repository as the workflow, a public repository, or in a published Docker
* container image.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder uses(java.lang.String uses) {
this.uses = uses;
return this;
}
/**
* Sets the value of {@link Step#getWith}
* @param with A map of the input parameters defined by the action.
* Each input parameter
* is a key/value pair. Input parameters are set as environment variables.
* The variable is prefixed with INPUT_ and converted to upper case.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@SuppressWarnings("unchecked")
public Builder with(java.util.Map with) {
this.with = (java.util.Map)with;
return this;
}
/**
* Sets the value of {@link Step#getEnv}
* @param env Sets environment variables for steps to use in the runner environment.
* You can also set environment variables for the entire workflow or a job.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder env(java.util.Map env) {
this.env = env;
return this;
}
/**
* Sets the value of {@link Step#getId}
* @param id A unique identifier for the step.
* You can use the id to reference the
* step in contexts.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder id(java.lang.String id) {
this.id = id;
return this;
}
/**
* Sets the value of {@link Step#getIfValue}
* @param ifValue You can use the if conditional to prevent a job from running unless a condition is met.
* You can use any supported context and expression to
* create a conditional.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder ifValue(java.lang.String ifValue) {
this.ifValue = ifValue;
return this;
}
/**
* Sets the value of {@link Step#getName}
* @param name A name for your step to display on GitHub.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder name(java.lang.String name) {
this.name = name;
return this;
}
/**
* Sets the value of {@link Step#getWorkingDirectory}
* @param workingDirectory Specifies a working directory for a step.
* Overrides a job's working directory.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder workingDirectory(java.lang.String workingDirectory) {
this.workingDirectory = workingDirectory;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link Step}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public Step build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link Step}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Step {
private final java.lang.String run;
private final java.lang.String uses;
private final java.util.Map with;
private final java.util.Map env;
private final java.lang.String id;
private final java.lang.String ifValue;
private final java.lang.String name;
private final java.lang.String workingDirectory;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.run = software.amazon.jsii.Kernel.get(this, "run", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.uses = software.amazon.jsii.Kernel.get(this, "uses", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.with = software.amazon.jsii.Kernel.get(this, "with", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(java.lang.Object.class)));
this.env = software.amazon.jsii.Kernel.get(this, "env", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.id = software.amazon.jsii.Kernel.get(this, "id", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.ifValue = software.amazon.jsii.Kernel.get(this, "if", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.name = software.amazon.jsii.Kernel.get(this, "name", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.workingDirectory = software.amazon.jsii.Kernel.get(this, "workingDirectory", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
@SuppressWarnings("unchecked")
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.run = builder.run;
this.uses = builder.uses;
this.with = (java.util.Map)builder.with;
this.env = builder.env;
this.id = builder.id;
this.ifValue = builder.ifValue;
this.name = builder.name;
this.workingDirectory = builder.workingDirectory;
}
@Override
public final java.lang.String getRun() {
return this.run;
}
@Override
public final java.lang.String getUses() {
return this.uses;
}
@Override
public final java.util.Map getWith() {
return this.with;
}
@Override
public final java.util.Map getEnv() {
return this.env;
}
@Override
public final java.lang.String getId() {
return this.id;
}
@Override
public final java.lang.String getIfValue() {
return this.ifValue;
}
@Override
public final java.lang.String getName() {
return this.name;
}
@Override
public final java.lang.String getWorkingDirectory() {
return this.workingDirectory;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
if (this.getRun() != null) {
data.set("run", om.valueToTree(this.getRun()));
}
if (this.getUses() != null) {
data.set("uses", om.valueToTree(this.getUses()));
}
if (this.getWith() != null) {
data.set("with", om.valueToTree(this.getWith()));
}
if (this.getEnv() != null) {
data.set("env", om.valueToTree(this.getEnv()));
}
if (this.getId() != null) {
data.set("id", om.valueToTree(this.getId()));
}
if (this.getIfValue() != null) {
data.set("if", om.valueToTree(this.getIfValue()));
}
if (this.getName() != null) {
data.set("name", om.valueToTree(this.getName()));
}
if (this.getWorkingDirectory() != null) {
data.set("workingDirectory", om.valueToTree(this.getWorkingDirectory()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("projen.github.workflows.Step"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Step.Jsii$Proxy that = (Step.Jsii$Proxy) o;
if (this.run != null ? !this.run.equals(that.run) : that.run != null) return false;
if (this.uses != null ? !this.uses.equals(that.uses) : that.uses != null) return false;
if (this.with != null ? !this.with.equals(that.with) : that.with != null) return false;
if (this.env != null ? !this.env.equals(that.env) : that.env != null) return false;
if (this.id != null ? !this.id.equals(that.id) : that.id != null) return false;
if (this.ifValue != null ? !this.ifValue.equals(that.ifValue) : that.ifValue != null) return false;
if (this.name != null ? !this.name.equals(that.name) : that.name != null) return false;
return this.workingDirectory != null ? this.workingDirectory.equals(that.workingDirectory) : that.workingDirectory == null;
}
@Override
public final int hashCode() {
int result = this.run != null ? this.run.hashCode() : 0;
result = 31 * result + (this.uses != null ? this.uses.hashCode() : 0);
result = 31 * result + (this.with != null ? this.with.hashCode() : 0);
result = 31 * result + (this.env != null ? this.env.hashCode() : 0);
result = 31 * result + (this.id != null ? this.id.hashCode() : 0);
result = 31 * result + (this.ifValue != null ? this.ifValue.hashCode() : 0);
result = 31 * result + (this.name != null ? this.name.hashCode() : 0);
result = 31 * result + (this.workingDirectory != null ? this.workingDirectory.hashCode() : 0);
return result;
}
}
}