Skip to content

Commit

Permalink
Merge pull request #1 from cerebruminc/INF-29
Browse files Browse the repository at this point in the history
INF-29: Disallow push direct to master in script
  • Loading branch information
Pehesi97 authored May 4, 2023
2 parents cb5cab3 + 1474a7e commit c831a83
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ for repository in "${REPOSITORIES[@]}"; do
-u ${USERNAME}:${GITHUB_TOKEN} \
--silent \
${GITHUB_API_URL}/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection

curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-u ${USERNAME}:${GITHUB_TOKEN} \
-H "X-GitHub-Api-Version: 2022-11-28" \
--silent \
https://api.github.com/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection/enforce_admins

curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-u ${USERNAME}:${GITHUB_TOKEN}\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection/required_status_checks \
-d '{"strict":true}'

elif [ "$BRANCH_PROTECTION_ENABLED" == "false" ]; then
curl \
-X DELETE \
Expand All @@ -168,6 +185,22 @@ for repository in "${REPOSITORIES[@]}"; do
-u ${USERNAME}:${GITHUB_TOKEN} \
--silent \
${GITHUB_API_URL}/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection

curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-u ${USERNAME}:${GITHUB_TOKEN} \
-H "X-GitHub-Api-Version: 2022-11-28" \
--silent \
https://api.github.com/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection/enforce_admins

curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-u ${USERNAME}:${GITHUB_TOKEN}\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${repository}/branches/${BRANCH_PROTECTION_NAME}/protection/required_status_checks

fi

echo "Completed [${repository}]"
Expand Down

0 comments on commit c831a83

Please sign in to comment.