Skip to content

Commit

Permalink
fix: bypass repository admin (id 5) in branch ruleset (#1791)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #1790
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Pending being told contrary information, hardcodes `actor_id: 5` for the
repository role to always be allowed to bypass branch protection
ruleset.

💖
  • Loading branch information
JoshuaKGoldberg authored Dec 21, 2024
1 parent 4e3642d commit 480c75d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/next/blocks/blockRepositoryBranchRuleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ export const blockRepositoryBranchRuleset = base.createBlock({
id: "branch-ruleset",
async send({ octokit }) {
await octokit.request("POST /repos/{owner}/{repo}/rulesets", {
bypass_actors: [
{
// This *seems* to be the Repository Admin role always?
// https://github.com/github/rest-api-description/issues/4406
actor_id: 5,
actor_type: "RepositoryRole",
bypass_mode: "always",
},
],
conditions: {
ref_name: {
exclude: [],
Expand Down
14 changes: 14 additions & 0 deletions src/steps/initializeBranchProtectionSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ describe("migrateBranchProtectionSettings", () => {
[
"POST /repos/{owner}/{repo}/rulesets",
{
"bypass_actors": [
{
"actor_id": 5,
"actor_type": "RepositoryRole",
"bypass_mode": "always",
},
],
"conditions": {
"ref_name": {
"exclude": [],
Expand Down Expand Up @@ -152,6 +159,13 @@ describe("migrateBranchProtectionSettings", () => {
[
"POST /repos/{owner}/{repo}/rulesets",
{
"bypass_actors": [
{
"actor_id": 5,
"actor_type": "RepositoryRole",
"bypass_mode": "always",
},
],
"conditions": {
"ref_name": {
"exclude": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export async function initializeBranchProtectionSettings(
) {
try {
await octokit.request("POST /repos/{owner}/{repo}/rulesets", {
bypass_actors: [
{
// This *seems* to be the Repository Admin role always?
// https://github.com/github/rest-api-description/issues/4406
actor_id: 5,
actor_type: "RepositoryRole",
bypass_mode: "always",
},
],
conditions: {
ref_name: {
exclude: [],
Expand Down

0 comments on commit 480c75d

Please sign in to comment.