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"]
}
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*"
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-*"
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-*"
Continue if the event ref matches a pattern.
action "branch-filter" {
uses = "actions/bin/filter@master"
args = "ref refs/pulls/*"
}
Continue if the issue or pull request has the following label
action "label-filter" {
uses = "actions/bin/filter@master"
args = "label urgent"
}
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"
}
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'"
}
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"]
}
Used to provide the logical opposite of other filters.
action "tag-filter" {
uses = "actions/bin/filter@master"
args = "not actor octocat"
}
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"]
}
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.