Struct Workflow

Source
pub struct Workflow {
    pub name: Option<String>,
    pub env: Option<Env>,
    pub run_name: Option<String>,
    pub on: Option<Event>,
    pub permissions: Option<Permissions>,
    pub jobs: Option<Jobs>,
    pub concurrency: Option<Concurrency>,
    pub defaults: Option<Defaults>,
    pub secrets: Option<IndexMap<String, Secret>>,
    pub timeout_minutes: Option<u32>,
}
Expand description

Represents the configuration for a GitHub workflow.

A workflow is a configurable automated process made up of one or more jobs. This struct defines the properties that can be set in a workflow YAML file for GitHub Actions, including the name, environment variables, permissions, jobs, concurrency settings, and more.

Fields§

§name: Option<String>

The name of the workflow. GitHub displays the names of your workflows under your repository’s “Actions” tab.

§env: Option<Env>

Environment variables that can be used in the workflow.

§run_name: Option<String>

The name for workflow runs generated from the workflow. GitHub displays the workflow run name in the list of workflow runs.

§on: Option<Event>

The event that triggers the workflow. This can include events like push, pull_request, etc.

§permissions: Option<Permissions>

Permissions granted to the GITHUB_TOKEN for the workflow.

§jobs: Option<Jobs>

The jobs that are defined in the workflow.

§concurrency: Option<Concurrency>

Concurrency settings for the workflow, allowing control over how jobs are executed.

§defaults: Option<Defaults>

Default settings for jobs in the workflow.

§secrets: Option<IndexMap<String, Secret>>

Secrets that can be used in the workflow, such as tokens or passwords.

§timeout_minutes: Option<u32>

The maximum number of minutes a job can run before it is canceled.

Implementations§

Source§

impl Workflow

Source

pub fn name(self, value: impl Into<String>) -> Self

Sets the name field of this struct.

Source

pub fn env(self, value: impl Into<Env>) -> Self

Sets the env field of this struct.

Source

pub fn run_name(self, value: impl Into<String>) -> Self

Sets the run_name field of this struct.

Source

pub fn on(self, value: impl Into<Event>) -> Self

Sets the on field of this struct.

Source

pub fn permissions(self, value: impl Into<Permissions>) -> Self

Sets the permissions field of this struct.

Source

pub fn jobs(self, value: impl Into<Jobs>) -> Self

Sets the jobs field of this struct.

Source

pub fn concurrency(self, value: impl Into<Concurrency>) -> Self

Sets the concurrency field of this struct.

Source

pub fn defaults(self, value: impl Into<Defaults>) -> Self

Sets the defaults field of this struct.

Source

pub fn secrets(self, value: impl Into<IndexMap<String, Secret>>) -> Self

Sets the secrets field of this struct.

Source

pub fn timeout_minutes(self, value: impl Into<u32>) -> Self

Sets the timeout_minutes field of this struct.

Source§

impl Workflow

Source

pub fn new<T: ToString>(name: T) -> Self

Creates a new Workflow with the specified name.

Source

pub fn to_string(&self) -> Result<String>

Converts the Workflow to a YAML string representation.

Source

pub fn add_job_when<T: ToString, J: Into<Job>>( self, cond: bool, id: T, job: J, ) -> Self

Adds a job to the workflow when a condition is met.

Source

pub fn add_job<T: ToString, J: Into<Job>>(self, id: T, job: J) -> Self

Adds a job to the workflow with the specified ID and job configuration.

Source

pub fn parse(yml: &str) -> Result<Self>

Parses a YAML string into a Workflow.

Source

pub fn generate(self) -> Result<()>

Generates the workflow using the Generate struct.

Source

pub fn add_event<T: Into<Event>>(self, that: T) -> Self

Adds an event to the workflow.

Source

pub fn add_event_when<T: Into<Event>>(self, cond: bool, that: T) -> Self

Adds an event to the workflow when a condition is met.

Source

pub fn add_env<T: Into<Env>>(self, new_env: T) -> Self

Adds an environment variable to the workflow.

Source

pub fn add_env_when<T: Into<Env>>(self, cond: bool, new_env: T) -> Self

Adds an environment variable to the workflow when a condition is met.

Source

pub fn get_id(&self, job: &Job) -> Option<&str>

Performs a reverse lookup to get the ID of a job.

Trait Implementations§

Source§

impl Clone for Workflow

Source§

fn clone(&self) -> Workflow

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Workflow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Workflow

Source§

fn default() -> Workflow

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Workflow

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Workflow

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,