-
Notifications
You must be signed in to change notification settings - Fork 59
84 lines (72 loc) · 2.45 KB
/
do-update-authors.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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 <git@stevenmyint.com>\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: action@github.com
committer_name: GitHub Actions
committer_email: actions@github.com
push: true