dguo / check-author-and-committer-action

GitHub Action for checking author and committer info
MIT License
0 stars 0 forks source link

Check whether commit author is a GitHub user #13

Open szepeviktor opened 2 years ago

szepeviktor commented 2 years ago

Hello @dguo! Have you thought about checking each commit in a PR against GitHub's user API?

This is my TravisCI script.

  Check_author()
  {
    local author="$1"
    local github_api_url="https://api.github.com/search/users"
    echo "Checking ${author} ..."
    test "${author%@users.noreply.github.com}" == "${author}" || return 0
    curl -s -G --data-urlencode "q=type:user in:email ${author}" "${github_api_url}" \
      | grep -F -x '  "total_count": 1,'
  }

  test -z "${TRAVIS_COMMIT_RANGE}" \
    || git show --no-patch --pretty="format:%ae" "${TRAVIS_COMMIT_RANGE}" \
    | sort -u \
    | while read -r author; do Check_author "${author}"; done