Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 59 additions & 39 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
use indexmap::IndexMap;
use serde::Deserialize;

use crate::common::{expr::BoE, Env, If};
use crate::common::{
expr::{BoE, LoE},
Env, If,
};

/// A GitHub Actions action definition.
#[derive(Deserialize)]
Expand Down Expand Up @@ -96,58 +99,75 @@ pub struct Composite {
}

/// An individual composite action step.
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case", untagged)]
pub enum Step {
RunShell(RunShell),
UseAction(UseAction),
}

/// A step that runs a command in a shell.
///
/// This is similar, but not identical to [`crate::workflow::job::Step`].
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct RunShell {
/// The command to run.
pub run: String,

/// The shell to run in.
pub shell: String,

/// An optional name for this step.
pub name: Option<String>,

/// An optional ID for this step.
pub struct Step {
/// An optional ID for this composite step.
pub id: Option<String>,

/// An optional expression that prevents this step from running unless it evaluates to `true`.
/// An optional expression that prevents this composite step from running unless it evaluates to `true`.
pub r#if: Option<If>,

/// An optional environment mapping for this step.
#[serde(default)]
pub env: Env,
/// An optional name for this composite step.
pub name: Option<String>,

/// An optional boolean or expression that, if `true`, prevents the job from failing when
/// this step fails.
/// this composite step fails.
#[serde(default)]
pub continue_on_error: BoE,

/// An optional working directory to run [`RunShell::run`] from.
pub working_directory: Option<String>,
/// The `run:` or `uses:` body for this composite step.
#[serde(flatten)]
pub body: StepBody,
}

/// A step that uses another GitHub Action.
/// The body of a composite action step.
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct UseAction {
/// The GitHub Action being used.
pub uses: String,

/// Any inputs to the action being used.
#[serde(default)]
pub with: IndexMap<String, String>,

/// An optional expression that prevents this step from running unless it evaluates to `true`.
pub r#if: Option<If>,
#[serde(rename_all = "kebab-case", untagged)]
pub enum StepBody {
/// A step that uses another GitHub Action.
Uses {
/// The GitHub Action being used.
uses: String,

/// Any inputs to the action being used.
#[serde(default)]
with: IndexMap<String, String>,

/// An optional expression that prevents this step from running unless it evaluates to `true`.
r#if: Option<If>,
},
/// A step that runs a command in a shell.
Run {
/// The command to run.
run: String,

/// The shell to run in.
shell: String,

/// An optional name for this step.
name: Option<String>,

/// An optional ID for this step.
id: Option<String>,

/// An optional expression that prevents this step from running unless it evaluates to `true`.
r#if: Option<If>,

/// An optional environment mapping for this step.
#[serde(default)]
env: LoE<Env>,

/// An optional boolean or expression that, if `true`, prevents the job from failing when
/// this step fails.
#[serde(default)]
continue_on_error: BoE,

/// An optional working directory to run [`RunShell::run`] from.
working_directory: Option<String>,
},
}

/// A `runs` definition for a Docker action.
Expand Down
23 changes: 23 additions & 0 deletions src/workflow/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ pub enum DeploymentEnvironment {
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Step {
/// An optional ID for this step.
pub id: Option<String>,

/// An optional expression that prevents this step from running unless it evaluates to `true`.
pub r#if: Option<If>,

/// An optional name for this step.
pub name: Option<String>,

/// An optional timeout for this step, in minutes.
pub timeout_minutes: Option<u64>,

/// An optional boolean or expression that, if `true`, prevents the job from failing when
/// this step fails.
#[serde(default)]
pub continue_on_error: BoE,

/// The `run:` or `uses:` body for this step.
#[serde(flatten)]
pub body: StepBody,
}
Expand All @@ -99,15 +111,26 @@ pub struct Step {
#[serde(rename_all = "kebab-case", untagged)]
pub enum StepBody {
Uses {
/// The GitHub Action being used.
uses: String,

/// Any inputs to the action being used.
#[serde(default)]
with: Env,
},
Run {
/// The command to run.
#[serde(deserialize_with = "crate::common::bool_is_string")]
run: String,

/// An optional working directory to run [`StepBody::Run::run`] from.
working_directory: Option<String>,

/// An optional shell to run in. Defaults to the job or workflow's
/// default shell.
shell: Option<String>,

/// An optional environment mapping for this step.
#[serde(default)]
env: LoE<Env>,
},
Expand Down
Loading