Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from SpringQL/ci/release-workflow-test
ci(fix): automate release workflow
- Loading branch information
Showing
2 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function get_current_branch_protection_setting() { | ||
# | ||
# gets branch protections setting, reformats put api body json | ||
# | ||
# environment variables | ||
# | ||
# REPO : github repository name for Owner/RepoName syntax | ||
# BRANCH: | ||
gh api --method GET repos/${REPO}/branches/${BRANCH}/protection | jq ' | ||
{ | ||
required_status_checks: null, | ||
restrictions: { | ||
users: .restrictions.users | [.[].login], | ||
teams: .restrictions.teams | [.[].slug], | ||
apps: .restrictions.apps | [.[].slug] | ||
}, | ||
enforce_admins: .enforce_admins.enabled , | ||
required_pull_request_reviews: { | ||
dismiss_stale_reviews: .required_pull_request_reviews.dismiss_stale_reviews, | ||
require_code_owner_reviews: .required_pull_request_reviews.require_code_owner_reviews, | ||
required_approving_review_count: .required_pull_request_reviews.required_approving_review_count | ||
}, | ||
required_linear_history: .required_linear_history.enabled, | ||
required_signatures: .required_signatures.enabled, | ||
allow_force_pushes: .allow_force_pushes.enabled, | ||
allow_deletions: .allow_deletions.enabled, | ||
block_reations: .block_creations.enabled, | ||
required_conversation_resolution: .required_conversation_resolution.enabled | ||
}' | ||
} | ||
|
||
function apply_branch_protection_setting() { | ||
gh api --method PUT -H "Accept: application/vnd.github+json" --input - repos/${REPO}/branches/${BRANCH}/protection | ||
} | ||
|
||
function enforce_admins_off() { | ||
get_current_branch_protection_setting | jq '.enforce_admins = false' | apply_branch_protection_setting | ||
} | ||
|
||
export -f enforce_admins_off | ||
|
||
function enforce_admins_on() { | ||
get_current_branch_protection_setting | jq '.enforce_admins = true' | apply_branch_protection_setting | ||
} | ||
|
||
export -f enforce_admins_on |