Skip to content

Latest commit

 

History

History

filter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Filters for GitHub Actions

This action includes common filters to stop workflows unless certain conditions are met.

For example, here is a workflow that publishes a package to npm when the master branch receives a push:

workflow "Build, Test, and Publish" {
  on = "push"
  resolves = ["Publish"]
}

action "Build" {
  uses = "actions/npm@master"
  args = "install"
}

action "Test" {
  needs = "Build"
  uses = "actions/npm@master"
  args = "test"
}

# Filter for master branch
action "Master" {
  needs = "Test"
  uses = "actions/bin/filter@master"
  args = "branch master"
}

action "Publish" {
  needs = "Master"
  uses = "actions/npm@master"
  args = "publish --access public"
  secrets = ["NPM_AUTH_TOKEN"]
}

Available filters

tag

Continue if the event is a tag.

action "tag-filter" {
  uses = "actions/bin/filter@master"
  args = "tag"
}

Optionally supply a pattern of tags to match:

  args = "tag v*"

branch

Continue if the event is a branch.

action "branch-filter" {
  uses = "actions/bin/filter@master"
  args = "branch"
}

Optionally supply a pattern of branches to match:

  args = "branch stable-*"

deleted_branch

Continue if the event which run on 'delete' is a branch.

action "branch-filter" {
  uses = "actions/bin/filter@master"
  args = "deleted_branch"
}

Optionally supply a pattern of branches to match:

  args = "deleted_branch stable-*"

ref

Continue if the event ref matches a pattern.

action "branch-filter" {
  uses = "actions/bin/filter@master"
  args = "ref refs/pulls/*"
}

label

Continue if the issue or pull request has the following label

action "label-filter" {
  uses = "actions/bin/filter@master"
  args = "label urgent"
}

issue_comment

Continue if the issue or pull request has the following issue_comment

action "issue-comment-filter" {
  uses = "actions/bin/filter@master"
  args = "issue_comment lgtm"
}

action

Continue if the event payload includes a matching action.

action "action-filter" {
  uses = "actions/bin/filter@master"
  args = "action synchronize"
}

This also supports multiple actions.

action "action-filter" {
  uses = "actions/bin/filter@master"
  args = "action 'opened|synchronize'"
}

actor

Continues when the initiator of a workflow matches a GitHub username.

action "actor-filter" {
  uses = "actions/bin/filter@master"
  args = "actor octocat"
}

This also supports multiple possible actors:

action "actor-filter" {
  uses = "actions/bin/filter@master"
  args = ["actor", "octocat", "torvalds"]
}

not

Used to provide the logical opposite of other filters.

action "tag-filter" {
  uses = "actions/bin/filter@master"
  args = "not actor octocat"
}

environment

Continue if the event payload includes a matching environment.

action "environment-filter" {
  uses = "actions/bin/filter@master"
  args = "environment production"
}

This also supports multiple environments.

action "environment-filter" {
  uses = "actions/bin/filter@master"
  args = ["environment", "staging", "production"]
}

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

Container images built with this project include third party materials. See THIRD_PARTY_NOTICE.md for details.