Move procedural code into a class #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Check commit authors on GitHub" | |
on: | |
pull_request: null | |
jobs: | |
commit_authors: | |
name: "Commit authors" | |
# No Debian https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
runs-on: "ubuntu-latest" | |
steps: | |
- | |
name: "Checkout repository" | |
uses: "actions/checkout@v3" | |
with: | |
fetch-depth: 0 | |
- | |
name: "Query commit email addresses from GitHub API" | |
run: | | |
Check_author() { | |
local AUTHOR="$1" | |
local GITHUB_API_URL="https://api.github.com/search/users" | |
echo "Checking ${AUTHOR} ..." | |
curl -s -G --data-urlencode "q=type:user in:email ${AUTHOR}" "${GITHUB_API_URL}" \ | |
| grep -F -x ' "total_count": 1,' | |
} | |
git show --no-patch --pretty="format:%ae" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \ | |
| sort -u \ | |
| while read -r AUTHOR; do Check_author "${AUTHOR}"; done |