-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update All Contributors Details in Raedme.md
- Loading branch information
1 parent
2c9395f
commit 133e54f
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Update Contributors | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 1' # Runs every Monday at 00:00 | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: pip install requests | ||
|
||
- name: Run update script | ||
run: python update_contributors.py | ||
|
||
- name: Commit changes | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add README.md | ||
git commit -m 'Update contributors list' | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import requests | ||
|
||
username = 'subhadipbhowmik' | ||
repo = '30-Days-Of-CPP' | ||
url = f'https://api.github.com/repos/{username}/{repo}/contributors' | ||
|
||
response = requests.get(url) | ||
contributors = response.json() | ||
|
||
contributors_list = [] | ||
|
||
for contributor in contributors: | ||
avatar_url = contributor['avatar_url'] | ||
login = contributor['login'] | ||
profile_url = contributor['html_url'] | ||
|
||
contributors_list.append(f"| ![avatar]({avatar_url}&s=50) | [{login}]({profile_url}) |") | ||
|
||
with open('README.md', 'r') as file: | ||
readme_content = file.readlines() | ||
|
||
# Find the index to insert contributors | ||
start_index = readme_content.index('| Avatar | Name | GitHub Profile |\n') + 2 | ||
|
||
# Remove existing contributors data | ||
while readme_content[start_index].startswith('| ![avatar]'): | ||
readme_content.pop(start_index) | ||
|
||
# Insert new contributors data | ||
for contributor in contributors_list: | ||
readme_content.insert(start_index, f"{contributor}\n") | ||
start_index += 1 | ||
|
||
# Write the updated content back to README.md | ||
with open('README.md', 'w') as file: | ||
file.writelines(readme_content) |