Skip to content

Commit 1f3df2b

Browse files
author
iamwatchdogs
committed
Added update-contributors-details.yml
1 parent e6c7400 commit 1f3df2b

File tree

1 file changed

+63
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)