Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 6f719be

Browse files
committed
allow run: to be a bool
...since GitHub Actions allows it. Signed-off-by: William Woodruff <[email protected]>
1 parent ff2454a commit 6f719be

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/common.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub type BoE = LoE<bool>;
176176
/// This only appears internally, as an intermediate type for `scalar_or_vector`.
177177
#[derive(Debug, Deserialize, PartialEq)]
178178
#[serde(untagged)]
179-
pub(crate) enum SoV<T> {
179+
enum SoV<T> {
180180
One(T),
181181
Many(Vec<T>),
182182
}
@@ -198,6 +198,32 @@ where
198198
SoV::deserialize(de).map(Into::into)
199199
}
200200

201+
/// A bool or string. This is useful for cases where GitHub Actions contextually
202+
/// reinterprets a YAML boolean as a string, e.g. `run: true` really means
203+
/// `run: 'true'`.
204+
#[derive(Debug, Deserialize, PartialEq)]
205+
#[serde(untagged)]
206+
enum BoS {
207+
Bool(bool),
208+
String(String),
209+
}
210+
211+
impl From<BoS> for String {
212+
fn from(value: BoS) -> Self {
213+
match value {
214+
BoS::Bool(b) => b.to_string(),
215+
BoS::String(s) => s,
216+
}
217+
}
218+
}
219+
220+
pub(crate) fn bool_is_string<'de, D>(de: D) -> Result<String, D::Error>
221+
where
222+
D: Deserializer<'de>,
223+
{
224+
BoS::deserialize(de).map(Into::into)
225+
}
226+
201227
#[cfg(test)]
202228
mod tests {
203229
use std::collections::HashMap;

src/workflow/job.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub enum StepBody {
8181
with: Env,
8282
},
8383
Run {
84+
#[serde(deserialize_with = "crate::common::bool_is_string")]
8485
run: String,
8586
working_directory: Option<String>,
8687
shell: Option<String>,

0 commit comments

Comments
 (0)