blob: 068236347725a8ef6ddf5ce2e413f7738104914b [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
17 }) { clientMutationId }
18}' -f repositoryId=${REPOSITORY_ID}
19
20gh api graphql -f query='
21mutation($repositoryId:ID!) {
22 createBranchProtectionRule(input: {
23 repositoryId: $repositoryId
24 pattern: "stable/*"
25 requiresApprovingReviews: true
26 requiredApprovingReviewCount: 1
27 requiresConversationResolution: true
28 requiresLinearHistory: true
29 }) { clientMutationId }
30}' -f repositoryId=${REPOSITORY_ID}