How to limit push operation to allow only commits that were signed with GPG on github

I have a Github repository that we share for our development. To ensure integrity, we decided to sign our commits and tags using GPG.

Now, how can I prevent developers from dragging unsigned commits to our repository on Github, as well as public keys with an open whitelist to allow push commits written with public keys with a green list

I checked a few push hooks, but did not find the method described above, and here it is.

remote="$1"
url="$2"

z40=0000000000000000000000000000000000000000

IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
    if [ "$local_sha" = $z40 ]
    then
    # Handle delete
    else
    if [ "$remote_sha" = $z40 ]
    then
        # New branch, examine all commits
        range="$local_sha"
    else
        # Update to existing branch, examine new commits
        range="$remote_sha..$local_sha"
    fi

    # Check for WIP commit
    commit=`git rev-list -n 1 --grep '^WIP' "$range"`
    if [ -n "$commit" ]
    then
        echo "Found WIP commit in $local_ref, not pushing"
        exit 1
     fi
    fi
 done
exit 0

How can i do this? Any concept or examples would be highly appreciated.

+4
1

, GitHub Enterprise pre-receive script, - ? , GPG script GitHub. GitHub.com, , , .

, ?

+1

Source: https://habr.com/ru/post/1670028/


All Articles