This repository was archived by the owner on May 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM alpine:latest
2+
3+ LABEL "com.github.actions.name" ="base branch filter"
4+ LABEL "com.github.actions.description" ="Filters pull request events based on their base branch."
5+ LABEL "com.github.actions.icon" ="filter"
6+ LABEL "com.github.actions.color" ="purple"
7+
8+ LABEL "repository" ="https://github.com/hashicorp/terraform-github-actions"
9+ LABEL "homepage" ="http://github.com/hashicorp/terraform-github-actions"
10+ LABEL "maintainer" =
"HashiCorp Terraform Team <[email protected] >" 11+
12+ RUN apk --no-cache add jq
13+
14+ COPY entrypoint.sh /entrypoint.sh
15+ ENTRYPOINT ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change 1+ # Base Branch Filter
2+ Filters pull request events depending on the base branch
3+ The base branch is the branch that the pull request will be merged into.
4+
5+ To use, set ` args ` to a regular expression that
6+ will be matched against the destination branch.
7+
8+ Note: This action only works on pull request events.
9+
10+ ## Example
11+ Filter on pull requests that have been merged into ` master ` :
12+ ``` hcl
13+ workflow "example" {
14+ resolves = "base-branch-filter"
15+ # Must be used on pull_request events.
16+ on = "pull_request"
17+ }
18+
19+ # First we use another filter to filter to only merged events.
20+ action "merged-prs-filter" {
21+ uses = "actions/bin/filter@master"
22+ args = "merged true"
23+ }
24+
25+ # Then we use this filter to ensure the branch matches "master".
26+ action "base-branch-filter" {
27+ uses = "hashicorp/terraform-github-actions/base-branc-filter@master"
28+ # We set args to our regex.
29+ args = "^master$"
30+ needs = "merged-prs-filter"
31+ }
32+ ```
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -e
4+
5+ regex=" $* "
6+ base_branch=$( jq -r .pull_request.base.ref " $GITHUB_EVENT_PATH " )
7+
8+ if " $actual " | grep -q " $regex " ; then
9+ echo " base branch \" $base_branch \" does not match \" $regex \" "
10+ exit 78
11+ fi
You can’t perform that action at this time.
0 commit comments