Skip to content

Commit

Permalink
fix: disallow push direct to master
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehesi97 committed May 4, 2023
1 parent cb5cab3 commit 1474a7e
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 1474a7e

Please sign in to comment.