Skip to content

Commit

Permalink
fix: Repo settings config on cortex-api (#10)
Browse files Browse the repository at this point in the history
* fix: Repo settings config on cortex-api

* fix: Solve the problem when we have repos that don't have EXISTING_CHECKS for a specific branch
  • Loading branch information
nathaclmpaulino authored Jun 28, 2023
1 parent 3f355d8 commit d2d3d95
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,25 @@ for repository in "${REPOSITORIES[@]}"; do
-H "Content-Type: application/json" \
-u ${USERNAME}:${GITHUB_TOKEN} \
${GITHUB_API_URL}/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection/required_status_checks)

EXISTING_CHECKS=$(echo "$REQUIRED_STATUS_CHECKS" | jq -rc '.checks')

EXISTING_CHECKS=$(echo "$REQUIRED_STATUS_CHECKS" | jq -rc '.checks')

if [ "$EXISTING_CHECKS" == "null" ]; then
echo "Check here the reason of there is no existing checks at this branch."
echo $( echo "$REQUIRED_STATUS_CHECKS" | jq -c '.message')
CURRENT_CHECKS=[]
else
CURRENT_CHECKS=$EXISTING_CHECKS;
fi;

# the argjson instead of just arg lets us pass the values not as strings
jq -n \
--argjson enforceAdmins $BRANCH_PROTECTION_ENFORCE_ADMINS \
--argjson dismissStaleReviews $BRANCH_PROTECTION_DISMISS \
--argjson codeOwnerReviews $BRANCH_PROTECTION_CODE_OWNERS \
--argjson reviewCount $BRANCH_PROTECTION_REQUIRED_REVIEWERS \
--argjson requiredStatusChecks $BRANCH_PROTECTION_REQUIRED_STATUS_CHECKS \
--argjson existingChecks "$EXISTING_CHECKS" \
--argjson existingChecks "$CURRENT_CHECKS" \
--arg restrictPushesTeamAllowed $BRANCH_PROTECTION_RESTRICT_PUSHES_TEAM_ALLOWED \
'{
required_status_checks:{
Expand Down

0 comments on commit d2d3d95

Please sign in to comment.