Skip to content

Commit 63f937a

Browse files
committed
feat(ci): add provider-specific guidance to CI safety validation errors
1 parent 5d8ee46 commit 63f937a

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/workflow/runner.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ pub fn validate_workflow_safety(
205205
}
206206

207207
if runner.ci && profile.approval != crate::workflow::profile::ApprovalMode::External {
208-
return Err("CI push requires approval=external".to_string());
208+
let msg = match runner.kind {
209+
RunnerKind::CircleCi => "CI push requires approval=external.\n\nDetected CircleCI.\nAdd approval = \"external\" to [workflow.ci-build-push] and gate the mutating CircleCI job behind:\n\n approve_image_push:\n type: approval",
210+
RunnerKind::GitHubActions => "CI push requires approval=external.\n\nDetected GitHub Actions.\nAdd approval = \"external\" to [workflow.ci-build-push] and run the job behind a protected GitHub Environment.",
211+
RunnerKind::Travis => "CI push requires approval=external.\n\nDetected Travis.\nAdd approval = \"external\" to [workflow.ci-build-push] and guard the mutating job with branch and environment variable conditions.",
212+
_ => "CI push requires approval=external",
213+
};
214+
return Err(msg.to_string());
209215
}
210216
}
211217

@@ -230,7 +236,13 @@ pub fn validate_workflow_safety(
230236

231237
if runner.ci {
232238
if profile.approval != crate::workflow::profile::ApprovalMode::External {
233-
return Err("CI deploy requires approval=external".to_string());
239+
let msg = match runner.kind {
240+
RunnerKind::CircleCi => "CI deploy requires approval=external.\n\nDetected CircleCI.\nAdd approval = \"external\" to [workflow.ci-build-push] and gate the mutating CircleCI job behind:\n\n approve_image_push:\n type: approval",
241+
RunnerKind::GitHubActions => "CI deploy requires approval=external.\n\nDetected GitHub Actions.\nAdd approval = \"external\" to [workflow.ci-build-push] and run the job behind a protected GitHub Environment.",
242+
RunnerKind::Travis => "CI deploy requires approval=external.\n\nDetected Travis.\nAdd approval = \"external\" to [workflow.ci-build-push] and guard the mutating job with branch and environment variable conditions.",
243+
_ => "CI deploy requires approval=external",
244+
};
245+
return Err(msg.to_string());
234246
}
235247

236248
if !profile.apply {

0 commit comments

Comments
 (0)