Skip to content

Commit ff4a46d

Browse files
MrSubidubiagu-z
andauthored
feat: add paths_ignore to pushes, pull requests and pull requests targets (#190)
* Add support for `paths-ignore` Co-authored-by: Agus Zubiaga <[email protected]> * Implement for `PullrequestTarget` * Add more comments --------- Co-authored-by: Agus Zubiaga <[email protected]>
1 parent 04a1093 commit ff4a46d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

crates/gh-workflow/src/event.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ pub enum PullRequestType {
565565
}
566566

567567
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
568+
#[serde(rename_all = "kebab-case")]
568569
#[setters(strip_option, into)]
569570
pub struct PullRequest {
570571
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@@ -573,6 +574,9 @@ pub struct PullRequest {
573574
pub branches: Vec<String>,
574575
#[serde(default, skip_serializing_if = "Vec::is_empty")]
575576
pub paths: Vec<String>,
577+
/// Ignore specific file paths
578+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
579+
pub paths_ignore: Vec<String>,
576580
}
577581

578582
impl PullRequest {
@@ -586,10 +590,17 @@ impl PullRequest {
586590
self
587591
}
588592

593+
/// Adds a file path to filter on
589594
pub fn add_path<S: Into<String>>(mut self, path: S) -> Self {
590595
self.paths.push(path.into());
591596
self
592597
}
598+
599+
/// Adds a file path to not trigger on
600+
pub fn add_ignored_path<S: Into<String>>(mut self, path: S) -> Self {
601+
self.paths_ignore.push(path.into());
602+
self
603+
}
593604
}
594605

595606
/// Types of pull request review events
@@ -656,6 +667,7 @@ impl PullRequestReviewComment {
656667
/// Configuration for pull request target events
657668
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
658669
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
670+
#[serde(rename_all = "kebab-case")]
659671
#[setters(strip_option, into)]
660672
pub struct PullRequestTarget {
661673
/// Filter on specific pull request event types
@@ -664,6 +676,11 @@ pub struct PullRequestTarget {
664676
/// Filter on specific branch names
665677
#[serde(default, skip_serializing_if = "Vec::is_empty")]
666678
pub branches: Vec<String>,
679+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
680+
pub paths: Vec<String>,
681+
/// Ignore specific file paths
682+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
683+
pub paths_ignore: Vec<String>,
667684
}
668685

669686
impl PullRequestTarget {
@@ -678,11 +695,24 @@ impl PullRequestTarget {
678695
self.branches.push(branch.into());
679696
self
680697
}
698+
699+
/// Adds a file path to filter on
700+
pub fn add_path<S: Into<String>>(mut self, path: S) -> Self {
701+
self.paths.push(path.into());
702+
self
703+
}
704+
705+
/// Adds a file path to not trigger on
706+
pub fn add_ignored_path<S: Into<String>>(mut self, path: S) -> Self {
707+
self.paths_ignore.push(path.into());
708+
self
709+
}
681710
}
682711

683712
/// Configuration for push events
684713
/// See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
685714
#[derive(Debug, Clone, Default, Deserialize, Serialize, Setters, PartialEq, Eq)]
715+
#[serde(rename_all = "kebab-case")]
686716
#[setters(strip_option, into)]
687717
pub struct Push {
688718
/// Filter on specific branch names
@@ -691,6 +721,9 @@ pub struct Push {
691721
/// Filter on specific file paths
692722
#[serde(default, skip_serializing_if = "Vec::is_empty")]
693723
pub paths: Vec<String>,
724+
/// Ignore specific file paths
725+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
726+
pub paths_ignore: Vec<String>,
694727
/// Filter on specific tags
695728
#[serde(default, skip_serializing_if = "Vec::is_empty")]
696729
pub tags: Vec<String>,
@@ -709,6 +742,12 @@ impl Push {
709742
self
710743
}
711744

745+
/// Adds a file path to not trigger on
746+
pub fn add_ignored_path<S: Into<String>>(mut self, path: S) -> Self {
747+
self.paths_ignore.push(path.into());
748+
self
749+
}
750+
712751
/// Adds a tag name to filter on
713752
pub fn add_tag<S: Into<String>>(mut self, tag: S) -> Self {
714753
self.tags.push(tag.into());

0 commit comments

Comments
 (0)