You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/README.md
+20-15Lines changed: 20 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,25 +4,30 @@ This directory contains GitHub Actions workflows for the TruffleHog repository.
4
4
5
5
## PR Approval Check (`pr-approval-check.yml`)
6
6
7
-
This workflow enforces that at least one PR approver must be a member of the `@trufflesecurity/product-eng` team or any of its child teams.
7
+
This workflow enforces that at least one PR approver must be an **active** member of the `@trufflesecurity/product-eng` team or any of its child teams.
8
8
9
9
### How it works:
10
10
11
11
1.**Triggers**: The workflow runs on:
12
-
-`pull_request_review` events when a review is submitted
13
-
-`pull_request` events when a PR is opened, reopened, or synchronized
14
-
15
-
2.**Approval Check**: The workflow:
16
-
- Fetches all reviews for the PR
17
-
- Filters for approved reviews
18
-
- Gets all child teams of `@trufflesecurity/product-eng`
19
-
- Checks if any approver is an active member of the parent team or any child team
12
+
-`pull_request_review` events when a review is submitted (`submitted` type)
13
+
-`pull_request` events when a PR is opened, reopened, or synchronized (`opened`, `reopened`, `synchronize` types)
14
+
15
+
2.**Approval Check Process**: The workflow:
16
+
- Fetches all reviews for the PR using the GitHub API
17
+
- Filters for reviews with state `APPROVED`
18
+
- Gets all child teams of `@trufflesecurity/product-eng` using `listChildInOrg` API
19
+
- Checks if any approver is an **active** member (not pending) of either:
20
+
- The parent `@trufflesecurity/product-eng` team, OR
21
+
- Any of its child teams
20
22
- Sets a commit status accordingly
21
23
22
24
3.**Status Check**: Creates a commit status named `product-eng-approval` with:
23
-
- ✅ **Success**: When at least one approver is a `@trufflesecurity/product-eng` or child team member
24
-
- ❌ **Failure**: When no `@trufflesecurity/product-eng` or child team members have approved
25
-
- ⏳ **Pending**: When waiting for reviews
25
+
- ✅ **Success**: When at least one approver is an active member of `@trufflesecurity/product-eng` or any child team
26
+
- ❌ **Failure**: When there are no approvals or there are approvals but none from active `@trufflesecurity/product-eng` members
27
+
28
+
### Error Handling
29
+
30
+
If there are errors listing reviews or checking team membership, the workflow reports a failure status and also fails itself.
26
31
27
32
### Branch Protection
28
33
@@ -31,13 +36,13 @@ To make this check required:
31
36
1. Go to Settings → Branches
32
37
2. Add or edit a branch protection rule for your main branch
33
38
3. Enable "Require status checks to pass before merging"
34
-
4. Add `product-eng-approval` to the required status checks
39
+
4. Add `pr-approval-check` to the required status checks
35
40
36
41
### Permissions
37
42
38
43
The workflow uses the default `GITHUB_TOKEN` which has sufficient permissions to:
39
44
- Read PR reviews
40
-
-Check team membership (for public teams)
45
+
-List child teams and check team membership (for public teams)
41
46
- Create commit statuses
42
47
43
-
**Note**: If the `product-eng` team or its child teams are private, you may need to use a personal access token with appropriate permissions.
48
+
**Note**: If the `product-eng` team or its child teams are private, you may need to use a personal access token with appropriate permissions. The Github API returns 404 for non-members and for lack of permissions.
0 commit comments