Do not double-process urls (#284) #87
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: Update AUTHORS.rst | |
# What this workflow does: | |
# 1. Update the AUTHORS.rst file | |
# 2. Git commit and push the file if there are changes. | |
on: # yamllint disable-line rule:truthy | |
workflow_dispatch: | |
push: | |
tags: | |
- "!*" | |
branches: | |
- master | |
jobs: | |
update-authors: | |
name: Update AUTHORS.rst file | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v3 | |
- name: Update AUTHORS.rst file | |
shell: python | |
run: | | |
import subprocess | |
git_authors = subprocess.run( | |
["git", "log", "--format=%aN <%aE>"], capture_output=True, check=True | |
).stdout.decode() | |
skip_list = ( | |
"Steven Myint", | |
"dependabot", | |
"pre-commit-ci", | |
"github-action", | |
"GitHub Actions", | |
"Sourcery AI", | |
) | |
authors = [ | |
author | |
for author in set(git_authors.strip().split("\n")) | |
if not author.startswith(skip_list) | |
] | |
authors.sort() | |
file_head = ( | |
".. This file is automatically generated/updated by a github actions workflow.\n" | |
".. Every manual change will be overwritten on push to master.\n" | |
".. You can find it here: ``.github/workflows/do-update-authors.yml``\n\n" | |
"Author\n" | |
"------\n" | |
"Steven Myint <[email protected]>\n\n" | |
"Additional contributions by (sorted by name)\n" | |
"--------------------------------------------\n" | |
) | |
with open("AUTHORS.rst", "w") as authors_file: | |
authors_file.write(file_head) | |
authors_file.write("- ") | |
authors_file.write("\n- ".join(authors)) | |
authors_file.write("\n") | |
- name: Check if diff | |
continue-on-error: true | |
run: > | |
git diff --exit-code AUTHORS.rst && | |
(echo "### No update" && exit 1) || (echo "### Commit update") | |
- uses: EndBug/add-and-commit@v9 | |
name: Commit and push if diff | |
if: success() | |
with: | |
add: AUTHORS.rst | |
message: 'chore: update AUTHORS.rst file with new author(s)' | |
author_name: GitHub Actions | |
author_email: [email protected] | |
committer_name: GitHub Actions | |
committer_email: [email protected] | |
push: true |