Skip to content

Commit 158214a

Browse files
authored
fix(github): make branch protection usable and wire workflow_id to its endpoint (#7308)
* fix(github): make branch protection usable and wire workflow_id to its endpoint `github_update_branch_protection` could not be called. `restrictions` was a required tool param with no subBlock anywhere in the block, so every run threw "Restrictions is required for GitHub Update Branch Protection" before the request. The other three body fields were `required: true` behind `mode: 'advanced'` subBlocks that are hidden by default, and their subBlock types did not match their param types. GitHub documents all four as required but nullable - "Set to null to disable" - so "required" there means present in the body, which `null` satisfies. Sim's `required: true` means the user must supply a non-empty value, which is strictly stronger. The params are now optional and the body builder supplies the explicit `null` GitHub demands for each field left unset, normalizing the editor's JSON strings and the dropdown's 'true'/'false' along the way. A `restrictions` subBlock is added. `workflow_id` rendered for `github_list_workflow_runs` but the tool declared no such param and always hit the repo-wide `/actions/runs`. It now selects `GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs`, which GitHub documents as accepting the same query filters. No subBlock id is renamed or removed and no visibility is flipped. * fix(github): name the branch-protection parse failure without echoing the input
1 parent bd49a7e commit 158214a

8 files changed

Lines changed: 508 additions & 44 deletions

File tree

apps/docs/content/docs/integrations/github.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,10 @@ Update branch protection rules for a specific branch, including status checks, r
10191019
| `owner` | string | Yes | Repository owner \(user or organization\) |
10201020
| `repo` | string | Yes | Repository name |
10211021
| `branch` | string | Yes | Branch name |
1022-
| `required_status_checks` | object | Yes | Required status check configuration \(null to disable\). Object with strict \(boolean\) and contexts \(string array\) |
1023-
| `enforce_admins` | boolean | Yes | Whether to enforce restrictions for administrators |
1024-
| `required_pull_request_reviews` | object | Yes | PR review requirements \(null to disable\). Object with optional required_approving_review_count, dismiss_stale_reviews, require_code_owner_reviews |
1025-
| `restrictions` | object | Yes | Push restrictions \(null to disable\). Object with users \(string array\) and teams \(string array\) |
1022+
| `required_status_checks` | object | No | Required status check configuration. Object with strict \(boolean\) and contexts \(string array\). Omit to disable status checks — GitHub receives an explicit null. |
1023+
| `enforce_admins` | boolean | No | Whether to enforce restrictions for administrators. Omit to disable admin enforcement — GitHub receives an explicit null. |
1024+
| `required_pull_request_reviews` | object | No | PR review requirements. Object with optional required_approving_review_count, dismiss_stale_reviews, require_code_owner_reviews. Omit to disable review requirements — GitHub receives an explicit null. |
1025+
| `restrictions` | object | No | Push restrictions, available only for organization-owned repositories. Object with users \(string array\), teams \(string array\) and optional apps \(string array\). Omit to disable push restrictions — GitHub receives an explicit null. |
10261026
| `apiKey` | string | Yes | GitHub Personal Access Token |
10271027

10281028
#### Output
@@ -1805,14 +1805,15 @@ Trigger a workflow dispatch event for a GitHub Actions workflow. The workflow mu
18051805

18061806
### GitHub List Workflow Runs
18071807

1808-
List workflow runs for a repository. Supports filtering by actor, branch, event, and status. Returns run details including status, conclusion, and links.
1808+
List workflow runs for a repository, or for a single workflow when a workflow ID or filename is given. Supports filtering by actor, branch, event, and status. Returns run details including status, conclusion, and links.
18091809

18101810
#### Input
18111811

18121812
| Parameter | Type | Required | Description |
18131813
| --------- | ---- | -------- | ----------- |
18141814
| `owner` | string | Yes | Repository owner \(user or organization\) |
18151815
| `repo` | string | Yes | Repository name |
1816+
| `workflow_id` | string | No | The ID of the workflow. You can also pass the workflow file name as a string \(e.g., ci.yml\). Omit to list runs across the whole repository. |
18161817
| `actor` | string | No | Filter by user who triggered the workflow |
18171818
| `branch` | string | No | Filter by branch name |
18181819
| `event` | string | No | Filter by event type \(e.g., push, pull_request, workflow_dispatch\) |

apps/sim/blocks/blocks/github.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,14 @@ export const GitHubBlock: BlockConfig<GitHubResponse> = {
993993
condition: { field: 'operation', value: 'github_update_branch_protection' },
994994
mode: 'advanced',
995995
},
996+
{
997+
id: 'restrictions',
998+
title: 'Push Restrictions',
999+
type: 'short-input',
1000+
placeholder: 'JSON: {"users":["octocat"],"teams":["admins"]}',
1001+
condition: { field: 'operation', value: 'github_update_branch_protection' },
1002+
mode: 'advanced',
1003+
},
9961004
// Issue operations parameters
9971005
{
9981006
id: 'title',
@@ -2407,9 +2415,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
24072415
ref: { type: 'string', description: 'Branch, tag, or commit reference' },
24082416
// Branch parameters
24092417
protected: { type: 'string', description: 'Protection status filter' },
2410-
required_status_checks: { type: 'string', description: 'Required status checks JSON' },
2418+
required_status_checks: { type: 'json', description: 'Required status checks JSON' },
24112419
enforce_admins: { type: 'boolean', description: 'Enforce for admins' },
2412-
required_pull_request_reviews: { type: 'string', description: 'Required PR reviews JSON' },
2420+
required_pull_request_reviews: { type: 'json', description: 'Required PR reviews JSON' },
2421+
restrictions: { type: 'json', description: 'Push restrictions JSON' },
24132422
// Issue parameters
24142423
labels: { type: 'string', description: 'Comma-separated labels' },
24152424
assignees: { type: 'string', description: 'Comma-separated assignees' },

apps/sim/tools/generated/tool-metadata.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)