-
Notifications
You must be signed in to change notification settings - Fork 162
56 lines (53 loc) · 2.1 KB
/
auto-add-contributors.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
name: Automatically Add Contributors
on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- closed
jobs:
update-contributors:
if: (github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Installing GitHub CLI
run: |
sudo apt install -y gh jq nodejs npm
- name: Install python packages
run: |
python -m pip install --upgrade pip
pip install -r .github/workflows/contributors/requirements.txt
- name: Retrieving contributors for commit ${{ github.sha }}
run: |
echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
echo "🔎 Getting all contributors from the ${{ github.ref }} branch."
PUSHED_CONTRIBUTORS=$(git shortlog -sne --no-merges ${{ github.event.before }}..${{ github.sha }})
echo "The contributors are: $PUSHED_CONTRIBUTORS"
- name: Running Python Script to Update .all-contributorsrc
run: |
echo "Running Python Script to Update .all-contributorsrc"
python .github/workflows/contributors/update_contributors.py
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Using all-contributors CLI to update files
run: |
echo "Using all-contributors CLI to update files"
npm i -D all-contributors-cli
npx all-contributors generate
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add -u
git diff-index --quiet HEAD || git commit -m "Update readme and contributors.qmd with contributors"
git push