Debian Codegraph @

core/.github/workflows/update-authors.yml

raw symbols SCIP
1 ---
2 name: Update AUTHORS.rst
3
4 # What this workflow does:
5 # 1. Update the AUTHORS.rst file
6 # 2. Git commit and push the file if there are changes.
7
8 on: # yamllint disable-line rule:truthy
9 workflow_dispatch:
10
11 push:
12 tags:
13 - "!*"
14 branches:
15 - main
16 - "test-me-*"
17
18 jobs:
19 update-authors:
20 name: Update AUTHORS.rst file
21 runs-on: ubuntu-latest
22 steps:
23 - uses: actions/checkout@v3
24 with:
25 fetch-depth: 0
26
27 - name: Set up Python
28 uses: actions/setup-python@v4
29 with:
30 python-version: "3.11"
31
32 - name: Update AUTHORS.rst file
33 shell: python
34 run: |
35 import subprocess
36
37 git_authors = subprocess.run(
38 ["git", "log", "--format=%aN <%aE>"], capture_output=True, check=True
39 ).stdout.decode()
40
41 skip_list = (
42 "Steven Myint",
43 "dependabot",
44 "pre-commit-ci",
45 "github-action",
46 "GitHub Actions",
47 )
48 authors = [
49 author
50 for author in set(git_authors.strip().split("\n"))
51 if not author.startswith(skip_list)
52 ]
53 authors.sort()
54
55 file_head = (
56 ".. This file is automatically generated/updated by a github actions workflow.\n"
57 ".. Every manual change will be overwritten on push to main.\n"
58 ".. You can find it here: ``.github/workflows/update-authors.yaml``\n"
59 ".. For more information see "
60 "`https://github.com/rstcheck/rstcheck/graphs/contributors`\n\n"
61 "Author\n"
62 "------\n"
63 "Steven Myint <[email protected]>\n\n"
64 "Additional contributions by (sorted by name)\n"
65 "--------------------------------------------\n"
66 )
67
68 with open("AUTHORS.rst", "w") as authors_file:
69 authors_file.write(file_head)
70 authors_file.write("- ")
71 authors_file.write("\n- ".join(authors))
72 authors_file.write("\n")
73
74 - name: Check if diff
75 continue-on-error: true
76 run: >
77 git diff --exit-code AUTHORS.rst &&
78 (echo "### No update" && exit 1) || (echo "### Commit update")
79
80 - uses: EndBug/add-and-commit@v9
81 name: Commit and push if diff
82 if: success()
83 with:
84 add: AUTHORS.rst
85 message: Update AUTHORS.rst file with new author(s)
86 author_name: GitHub Actions
87 author_email: [email protected]
88 committer_name: GitHub Actions
89 committer_email: [email protected]
90 push: true