-
Notifications
You must be signed in to change notification settings - Fork 9
63 lines (52 loc) · 1.69 KB
/
update-contributors-details.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
name: update-contributor-details
on:
pull_request_target:
types: [closed]
branches: [main]
env:
REPO_NAME: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
update-by-pr:
if: ${{ github.event.pull_request.title != 'init' && github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checking out the repo
uses: actions/checkout@v4.1.0
- name: Setup Python
uses: actions/setup-python@v4.7.1
- name: Getting PR details
run: |
touch pr.json
gh pr view $PR_NUMBER --json author,url,files > pr.json
- name: Updating log file
run: |
if [ ! -d ".github/data" ]; then
mkdir .github/data
echo "Create `.github/data` directory"
fi
python .github/scripts/update_contributors_log.py
cat .github/data/contributors-log.json
- name: Updating index.md file
run: |
python .github/scripts/update_index_md.py
cat index.md
- name: Remove unwanted files
run: rm pr.json
- name: Commit and Push
run: |
if [ "$(git status | grep 'Changes not staged\|Untracked files')" ]; then
git diff
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add .
git commit -m "Updated Contributors Details"
git push origin main
echo "Pushed the update successfully"
else
echo "Nothing to push"
exit 1
fi