From 133e54f3dc45394b48fc1ca0e9e5556b5d945325 Mon Sep 17 00:00:00 2001 From: Shubhadip Bhowmik Date: Fri, 24 May 2024 02:38:46 +0530 Subject: [PATCH] Update All Contributors Details in Raedme.md --- .github/workflows/update_contributors.yml | 35 ++++++++++++++++++++++ README.md | 9 +++++- update_contributors.py | 36 +++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update_contributors.yml create mode 100644 update_contributors.py diff --git a/.github/workflows/update_contributors.yml b/.github/workflows/update_contributors.yml new file mode 100644 index 000000000..c388888fc --- /dev/null +++ b/.github/workflows/update_contributors.yml @@ -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 diff --git a/README.md b/README.md index 690628c30..114e36bd6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ Welcome to the 30 Days of CPP challenge! 30 days of CPP programming challenge is ![30-Days-CPP](./static/img/30-days-cpp.png) - ## What is 30 Days of CPP? 30 Days of CPP is a programming challenge designed to help individuals enhance their proficiency in C++ by solving daily coding problems, implementing algorithms, and exploring various aspects of the language. @@ -104,6 +103,14 @@ If you would like to contribute additional exercises, improvements, or correctio Happy coding! +![Line](https://user-images.githubusercontent.com/85225156/171937799-8fc9e255-9889-4642-9c92-6df85fb86e82.gif) + +## Contributors List + +| Avatar | Name | GitHub Profile | +|--------|------|----------------| + + ## License diff --git a/update_contributors.py b/update_contributors.py new file mode 100644 index 000000000..499618f1a --- /dev/null +++ b/update_contributors.py @@ -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)