blob: 3d83cad86212c951be7dbde0279280fed89adbf0 [file] [log] [blame]
Mohammed Naser0cacea42023-02-19 21:55:22 +00001#!/bin/bash -xe
Mohammed Naser94a8cb92023-02-19 20:42:58 +00002
Mohammed Naser2fec6412023-03-01 12:55:37 +00003gh repo fork ${1} --org vexxhost
Mohammed Naser94a8cb92023-02-19 20:42:58 +00004
Mohammed Naser2fec6412023-03-01 12:55:37 +00005REPOSITORY_ID_QUERY="{repository(owner: \"vexxhost\", name: \"${1##*/}\"){id}}"
Mohammed Naser94a8cb92023-02-19 20:42:58 +00006REPOSITORY_ID=$(gh api graphql -f query="${REPOSITORY_ID_QUERY}" -q .data.repository.id)
7
8gh api graphql -f query='
9mutation($repositoryId:ID!) {
10 createBranchProtectionRule(input: {
11 repositoryId: $repositoryId
12 pattern: "master"
13 requiresApprovingReviews: true
14 requiredApprovingReviewCount: 1
15 requiresConversationResolution: true
16 requiresLinearHistory: true
Mohammed Naseree6a9e62023-03-27 22:18:38 +000017 isAdminEnforced: false
Mohammed Naser94a8cb92023-02-19 20:42:58 +000018 }) { clientMutationId }
19}' -f repositoryId=${REPOSITORY_ID}
20
21gh api graphql -f query='
22mutation($repositoryId:ID!) {
23 createBranchProtectionRule(input: {
24 repositoryId: $repositoryId
25 pattern: "stable/*"
26 requiresApprovingReviews: true
27 requiredApprovingReviewCount: 1
28 requiresConversationResolution: true
29 requiresLinearHistory: true
Mohammed Naseree6a9e62023-03-27 22:18:38 +000030 isAdminEnforced: false
Mohammed Naser94a8cb92023-02-19 20:42:58 +000031 }) { clientMutationId }
32}' -f repositoryId=${REPOSITORY_ID}