Skip to content

Commit 505479b

Browse files
committed
Added update-contributors-details.yml
1 parent bf0331e commit 505479b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: update-contributor-details
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
env:
11+
REPO_NAME: ${{ github.repository }}
12+
PR_NUMBER: ${{ github.event.pull_request.number }}
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
15+
jobs:
16+
update-by-pr:
17+
if: ${{ github.event.pull_request.title != 'init' }}
18+
runs-on: ubuntu-latest
19+
20+
permissions:
21+
contents: write
22+
23+
steps:
24+
- name: Checking out the repo
25+
uses: actions/[email protected]
26+
27+
- name: Setup Python
28+
uses: actions/[email protected]
29+
30+
- name: Getting PR details
31+
run: |
32+
touch pr.json
33+
gh pr view $PR_NUMBER --json author,url,files > pr.json
34+
35+
- name: Updating log file
36+
run: |
37+
if [ ! -d ".github/data" ]; then
38+
mkdir .github/data
39+
echo "Create `.github/data` directory"
40+
fi
41+
python .github/scripts/update_contributors_log.py
42+
cat .github/data/contributors-log.json
43+
44+
- name: Updating index.md file
45+
run: |
46+
python .github/scripts/update_index_md.py
47+
cat index.md
48+
49+
- name: Remove unwanted files
50+
run: rm pr.json
51+
52+
- name: Commit and Push
53+
run: |
54+
if [ "$(git status | grep 'Changes not staged\|Untracked files')" ]; then
55+
git diff
56+
git config --global user.email "[email protected]"
57+
git config --global user.name "GitHub Actions"
58+
git add .
59+
git commit -m "Updated Contributors Details"
60+
git push origin main
61+
echo "Pushed the update successfully"
62+
else
63+
echo "Nothing to push"
64+
exit 1
65+
fi

0 commit comments

Comments
 (0)