From 3c8d7dc2fd5d8b86de5753579a6a56cf52ad593d Mon Sep 17 00:00:00 2001 From: Mugundh Date: Sun, 20 Oct 2024 20:12:33 +0530 Subject: [PATCH 1/5] Automated project structure updation using github workflows and action bot --- .github/scripts/update_structure.py | 101 ++++++++++++++++++++++++++++ .github/workflows/update-readme.yml | 38 +++++++++++ README.md | 4 ++ 3 files changed, 143 insertions(+) create mode 100644 .github/scripts/update_structure.py create mode 100644 .github/workflows/update-readme.yml diff --git a/.github/scripts/update_structure.py b/.github/scripts/update_structure.py new file mode 100644 index 0000000..25591be --- /dev/null +++ b/.github/scripts/update_structure.py @@ -0,0 +1,101 @@ +import os +import github +from github import Github + +# Helper function to recursively build the repo structure and include file extensions +def get_repo_structure(path='.', prefix=''): + structure = [] + try: + items = sorted(os.listdir(path)) + except FileNotFoundError: + print(f"Path not found: {path}") + return structure + + for i, item in enumerate(items): + if item.startswith('.'): + continue # Skip hidden files and directories + item_path = os.path.join(path, item) + is_last = i == len(items) - 1 + current_prefix = '└── ' if is_last else '├── ' + + if os.path.isdir(item_path): + # Directory case + structure.append(f"{prefix}{current_prefix}{item}/") + next_prefix = prefix + (' ' if is_last else '│ ') + structure.extend(get_repo_structure(item_path, next_prefix)) + else: + # File case with extension + file_name, file_extension = os.path.splitext(item) + structure.append(f"{prefix}{current_prefix}{file_name}{file_extension}") + + return structure + +# Function to update the repo_structure.txt file +def update_structure_file(structure): + try: + with open('repo_structure.txt', 'w') as f: + f.write('\n'.join(structure)) + print("repo_structure.txt updated successfully.") + except IOError as e: + print(f"Error writing to repo_structure.txt: {e}") + +# Function to update the README.md with the new structure +def update_README(structure): + try: + with open('README.md', 'r') as f: + content = f.read() + except FileNotFoundError: + print("README.md not found.") + return + + start_marker = '' + end_marker = '' + + start_index = content.find(start_marker) + end_index = content.find(end_marker) + + if start_index != -1 and end_index != -1: + new_content = ( + content[:start_index + len(start_marker)] + + '\n```\n' + '\n'.join(structure) + '\n```\n' + + content[end_index:] + ) + try: + with open('README.md', 'w') as f: + f.write(new_content) + print("README.md updated with new structure.") + except IOError as e: + print(f"Error writing to README.md: {e}") + else: + print("Markers not found in README.md. Structure not updated.") + +# Main function to compare and update repository structure +def main(): + gh_token = os.getenv('GH_TOKEN') + gh_repo = os.getenv('GITHUB_REPOSITORY') + + if not gh_token or not gh_repo: + print("Environment variables GH_TOKEN and GITHUB_REPOSITORY must be set.") + return + + g = Github(gh_token) + repo = g.get_repo(gh_repo) + + current_structure = get_repo_structure() + + try: + # Fetch the contents of repo_structure.txt from GitHub + contents = repo.get_contents("repo_structure.txt") + existing_structure = contents.decoded_content.decode().split('\n') + except github.GithubException: + existing_structure = None + + if current_structure != existing_structure: + update_structure_file(current_structure) + update_README(current_structure) + print("Repository structure updated.") + else: + print("No changes in repository structure.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml new file mode 100644 index 0000000..d42be2a --- /dev/null +++ b/.github/workflows/update-readme.yml @@ -0,0 +1,38 @@ +name: Update Repository structure + +on: + schedule: + - cron: '0 * * * *' # Run every hour + workflow_dispatch: # Allow manual triggering + push: + branches: + - main + +jobs: + detect-and-update-structure: + 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.12 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install PyGithub + + - name: Run update script + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: python .github/scripts/update_structure.py + + - name: Commit and push if changed + run: | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + git add . + git diff --quiet && git diff --staged --quiet || (git commit -m "Update repo structure" && git push) \ No newline at end of file diff --git a/README.md b/README.md index 90e4113..1a3d454 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ With **Research-Nexas**, the future of research collaboration is smarter, faster +## Project Structure + + + ## 📚 Table of Contents From d545bc48df08b56c6ff4cfeff46f1a291916f217 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 14:43:01 +0000 Subject: [PATCH 2/5] Update repo structure --- README.md | 106 +++++++++++++++++++++++++++++++++++++++++++++ repo_structure.txt | 104 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 repo_structure.txt diff --git a/README.md b/README.md index 1a3d454..5cc3f74 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,112 @@ With **Research-Nexas**, the future of research collaboration is smarter, faster ## Project Structure +``` +├── Code_of_Conduct.md +├── Contributing.md +├── Image/ +│ ├── 212284100-561aa473-3905-4a80-b561-0d28506553ee.gif +│ ├── 329829127-e79eb6de-81b1-4ffb-b6ed-f018bb977e88.png +│ ├── Images +│ └── hacktober.png +├── LICENSE +├── README.md +├── Research-Nexas - Application Architecture.png +├── backend/ +│ ├── profile.js +│ └── stk_profile.js +├── config/ +│ └── mysql_connection.js +├── file_upload/ +│ ├── form_db.js +│ ├── upload.js +│ └── uploads/ +│ ├── 1728284943729-pebble watch invoice.pdf +│ ├── 1728291889782-Essential_documents_for_admission.txt +│ └── 1728962999779-Screenshot from 2024-10-09 10-26-04.png +├── login-system/ +│ ├── dbServer.js +│ ├── login.js +│ ├── logout.js +│ ├── notification.js +│ └── token.js +├── package-lock.json +├── package.json +├── public/ +│ ├── allotment.html +│ ├── choose-file.html +│ ├── choose-signup-file.html +│ ├── contact-us.html +│ ├── contributor.html +│ ├── css/ +│ │ ├── choosefile.css +│ │ ├── contact-us.css +│ │ ├── contributor.css +│ │ ├── faculty_styling.css +│ │ ├── faq_style.css +│ │ ├── form.css +│ │ ├── login_style.css +│ │ ├── main_page_style.css +│ │ ├── privacy_style.css +│ │ ├── profile.css +│ │ ├── stk_mainstyling.css +│ │ ├── style.css +│ │ └── uploadfile.css +│ ├── dashboard.html +│ ├── fac_login.html +│ ├── faculty.html +│ ├── form_filling.html +│ ├── gitContributors.html +│ ├── images/ +│ │ ├── Design 1.webp +│ │ ├── badge.webp +│ │ ├── badges.webp +│ │ ├── boost.webp +│ │ ├── calm.jpg +│ │ ├── career.webp +│ │ ├── career_pic.webp +│ │ ├── collaborate.webp +│ │ ├── connect.webp +│ │ ├── connectpeers.webp +│ │ ├── dark_mode.webp +│ │ ├── explorepapers.webp +│ │ ├── follow.webp +│ │ ├── logo.webp +│ │ ├── moon.webp +│ │ ├── plagiarism.webp +│ │ ├── sun.webp +│ │ ├── upload-image.webp +│ │ └── wave.webp +│ ├── index.html +│ ├── login.html +│ ├── main_page.html +│ ├── password_reset.html +│ ├── privacy_policy.html +│ ├── script/ +│ │ ├── approval.js +│ │ ├── contributor.js +│ │ ├── main-page-script.js +│ │ ├── paper_allotment.js +│ │ ├── script.js +│ │ ├── slider.js +│ │ └── stk_mainpage.js +│ ├── signup.html +│ ├── stk_dashboard.html +│ ├── stk_login.html +│ ├── stk_mainpage.html +│ ├── stk_signup.html +│ └── upload_file.html +├── pull_request_template.md +├── stakeholder/ +│ ├── allotment.js +│ ├── evaluation.js +│ ├── faculty.js +│ ├── login.js +│ └── stk_approval.js +└── views/ + ├── fac_signup.ejs + └── stk_papers.ejs +``` ## 📚 Table of Contents diff --git a/repo_structure.txt b/repo_structure.txt new file mode 100644 index 0000000..fbcbebe --- /dev/null +++ b/repo_structure.txt @@ -0,0 +1,104 @@ +├── Code_of_Conduct.md +├── Contributing.md +├── Image/ +│ ├── 212284100-561aa473-3905-4a80-b561-0d28506553ee.gif +│ ├── 329829127-e79eb6de-81b1-4ffb-b6ed-f018bb977e88.png +│ ├── Images +│ └── hacktober.png +├── LICENSE +├── README.md +├── Research-Nexas - Application Architecture.png +├── backend/ +│ ├── profile.js +│ └── stk_profile.js +├── config/ +│ └── mysql_connection.js +├── file_upload/ +│ ├── form_db.js +│ ├── upload.js +│ └── uploads/ +│ ├── 1728284943729-pebble watch invoice.pdf +│ ├── 1728291889782-Essential_documents_for_admission.txt +│ └── 1728962999779-Screenshot from 2024-10-09 10-26-04.png +├── login-system/ +│ ├── dbServer.js +│ ├── login.js +│ ├── logout.js +│ ├── notification.js +│ └── token.js +├── package-lock.json +├── package.json +├── public/ +│ ├── allotment.html +│ ├── choose-file.html +│ ├── choose-signup-file.html +│ ├── contact-us.html +│ ├── contributor.html +│ ├── css/ +│ │ ├── choosefile.css +│ │ ├── contact-us.css +│ │ ├── contributor.css +│ │ ├── faculty_styling.css +│ │ ├── faq_style.css +│ │ ├── form.css +│ │ ├── login_style.css +│ │ ├── main_page_style.css +│ │ ├── privacy_style.css +│ │ ├── profile.css +│ │ ├── stk_mainstyling.css +│ │ ├── style.css +│ │ └── uploadfile.css +│ ├── dashboard.html +│ ├── fac_login.html +│ ├── faculty.html +│ ├── form_filling.html +│ ├── gitContributors.html +│ ├── images/ +│ │ ├── Design 1.webp +│ │ ├── badge.webp +│ │ ├── badges.webp +│ │ ├── boost.webp +│ │ ├── calm.jpg +│ │ ├── career.webp +│ │ ├── career_pic.webp +│ │ ├── collaborate.webp +│ │ ├── connect.webp +│ │ ├── connectpeers.webp +│ │ ├── dark_mode.webp +│ │ ├── explorepapers.webp +│ │ ├── follow.webp +│ │ ├── logo.webp +│ │ ├── moon.webp +│ │ ├── plagiarism.webp +│ │ ├── sun.webp +│ │ ├── upload-image.webp +│ │ └── wave.webp +│ ├── index.html +│ ├── login.html +│ ├── main_page.html +│ ├── password_reset.html +│ ├── privacy_policy.html +│ ├── script/ +│ │ ├── approval.js +│ │ ├── contributor.js +│ │ ├── main-page-script.js +│ │ ├── paper_allotment.js +│ │ ├── script.js +│ │ ├── slider.js +│ │ └── stk_mainpage.js +│ ├── signup.html +│ ├── stk_dashboard.html +│ ├── stk_login.html +│ ├── stk_mainpage.html +│ ├── stk_signup.html +│ └── upload_file.html +├── pull_request_template.md +├── stakeholder/ +│ ├── allotment.js +│ ├── evaluation.js +│ ├── faculty.js +│ ├── login.js +│ └── stk_approval.js +└── views/ + ├── fac_signup.ejs + └── stk_papers.ejs \ No newline at end of file From 74404428a6d177158420dced947d5a5149d3cc91 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 15:17:43 +0000 Subject: [PATCH 3/5] Update repo structure --- README.md | 1 + repo_structure.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 5cc3f74..69b1087 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ With **Research-Nexas**, the future of research collaboration is smarter, faster │ ├── stk_signup.html │ └── upload_file.html ├── pull_request_template.md +├── repo_structure.txt ├── stakeholder/ │ ├── allotment.js │ ├── evaluation.js diff --git a/repo_structure.txt b/repo_structure.txt index fbcbebe..50feef6 100644 --- a/repo_structure.txt +++ b/repo_structure.txt @@ -93,6 +93,7 @@ │ ├── stk_signup.html │ └── upload_file.html ├── pull_request_template.md +├── repo_structure.txt ├── stakeholder/ │ ├── allotment.js │ ├── evaluation.js From 07358a3d9b28ea5823db365a31cfc31243e777a5 Mon Sep 17 00:00:00 2001 From: Mugundh Date: Thu, 24 Oct 2024 16:22:55 +0530 Subject: [PATCH 4/5] Added project structure separately --- .github/scripts/update_structure.py | 12 ++++++------ .github/workflows/update-readme.yml | 1 + PROJECT_STRUCTURE.md | 4 ++++ README.md | 5 ++--- 4 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 PROJECT_STRUCTURE.md diff --git a/.github/scripts/update_structure.py b/.github/scripts/update_structure.py index 25591be..fdf8db3 100644 --- a/.github/scripts/update_structure.py +++ b/.github/scripts/update_structure.py @@ -42,10 +42,10 @@ def update_structure_file(structure): # Function to update the README.md with the new structure def update_README(structure): try: - with open('README.md', 'r') as f: + with open('PROJECT_STRUCTURE.md', 'r') as f: content = f.read() except FileNotFoundError: - print("README.md not found.") + print("PROJECT_STRUCTURE.md not found.") return start_marker = '' @@ -61,13 +61,13 @@ def update_README(structure): content[end_index:] ) try: - with open('README.md', 'w') as f: + with open('PROJECT_STRUCTURE.md', 'w') as f: f.write(new_content) - print("README.md updated with new structure.") + print("PROJECT_STRUCTURE.md updated with new structure.") except IOError as e: - print(f"Error writing to README.md: {e}") + print(f"Error writing to PROJECT_STRUCTURE.md: {e}") else: - print("Markers not found in README.md. Structure not updated.") + print("Markers not found in PROJECT_STRUCTURE.md. Structure not updated.") # Main function to compare and update repository structure def main(): diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index d42be2a..6176e8e 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -7,6 +7,7 @@ on: push: branches: - main + - master jobs: detect-and-update-structure: diff --git a/PROJECT_STRUCTURE.md b/PROJECT_STRUCTURE.md new file mode 100644 index 0000000..e2e0db4 --- /dev/null +++ b/PROJECT_STRUCTURE.md @@ -0,0 +1,4 @@ +## Project Structure ✨ + + + \ No newline at end of file diff --git a/README.md b/README.md index 1a3d454..4fbe392 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,9 @@ With **Research-Nexas**, the future of research collaboration is smarter, faster -## Project Structure +## Project Structure ✨ - - +Check the project structure here [Project Structure](PROJECT_STRUCTURE.md) ## 📚 Table of Contents From 63787b48c194f8c9e73eeb8cd7c3c6657ad0312e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:53:54 +0000 Subject: [PATCH 5/5] Update repo structure --- PROJECT_STRUCTURE.md | 108 +++++++++++++++++++++++++++++++++++++++++++ repo_structure.txt | 1 + 2 files changed, 109 insertions(+) diff --git a/PROJECT_STRUCTURE.md b/PROJECT_STRUCTURE.md index e2e0db4..d63929a 100644 --- a/PROJECT_STRUCTURE.md +++ b/PROJECT_STRUCTURE.md @@ -1,4 +1,112 @@ ## Project Structure ✨ +``` +├── Code_of_Conduct.md +├── Contributing.md +├── Image/ +│ ├── 212284100-561aa473-3905-4a80-b561-0d28506553ee.gif +│ ├── 329829127-e79eb6de-81b1-4ffb-b6ed-f018bb977e88.png +│ ├── Images +│ └── hacktober.png +├── LICENSE +├── PROJECT_STRUCTURE.md +├── README.md +├── Research-Nexas - Application Architecture.png +├── backend/ +│ ├── profile.js +│ └── stk_profile.js +├── config/ +│ └── mysql_connection.js +├── file_upload/ +│ ├── form_db.js +│ ├── upload.js +│ └── uploads/ +│ ├── 1728284943729-pebble watch invoice.pdf +│ ├── 1728291889782-Essential_documents_for_admission.txt +│ └── 1728962999779-Screenshot from 2024-10-09 10-26-04.png +├── login-system/ +│ ├── dbServer.js +│ ├── login.js +│ ├── logout.js +│ ├── notification.js +│ └── token.js +├── package-lock.json +├── package.json +├── public/ +│ ├── allotment.html +│ ├── choose-file.html +│ ├── choose-signup-file.html +│ ├── contact-us.html +│ ├── contributor.html +│ ├── css/ +│ │ ├── choosefile.css +│ │ ├── contact-us.css +│ │ ├── contributor.css +│ │ ├── faculty_styling.css +│ │ ├── faq_style.css +│ │ ├── form.css +│ │ ├── login_style.css +│ │ ├── main_page_style.css +│ │ ├── privacy_style.css +│ │ ├── profile.css +│ │ ├── stk_mainstyling.css +│ │ ├── style.css +│ │ └── uploadfile.css +│ ├── dashboard.html +│ ├── fac_login.html +│ ├── faculty.html +│ ├── form_filling.html +│ ├── gitContributors.html +│ ├── images/ +│ │ ├── Design 1.webp +│ │ ├── badge.webp +│ │ ├── badges.webp +│ │ ├── boost.webp +│ │ ├── calm.jpg +│ │ ├── career.webp +│ │ ├── career_pic.webp +│ │ ├── collaborate.webp +│ │ ├── connect.webp +│ │ ├── connectpeers.webp +│ │ ├── dark_mode.webp +│ │ ├── explorepapers.webp +│ │ ├── follow.webp +│ │ ├── logo.webp +│ │ ├── moon.webp +│ │ ├── plagiarism.webp +│ │ ├── sun.webp +│ │ ├── upload-image.webp +│ │ └── wave.webp +│ ├── index.html +│ ├── login.html +│ ├── main_page.html +│ ├── password_reset.html +│ ├── privacy_policy.html +│ ├── script/ +│ │ ├── approval.js +│ │ ├── contributor.js +│ │ ├── main-page-script.js +│ │ ├── paper_allotment.js +│ │ ├── script.js +│ │ ├── slider.js +│ │ └── stk_mainpage.js +│ ├── signup.html +│ ├── stk_dashboard.html +│ ├── stk_login.html +│ ├── stk_mainpage.html +│ ├── stk_signup.html +│ └── upload_file.html +├── pull_request_template.md +├── repo_structure.txt +├── stakeholder/ +│ ├── allotment.js +│ ├── evaluation.js +│ ├── faculty.js +│ ├── login.js +│ └── stk_approval.js +└── views/ + ├── fac_signup.ejs + └── stk_papers.ejs +``` \ No newline at end of file diff --git a/repo_structure.txt b/repo_structure.txt index 50feef6..4efc105 100644 --- a/repo_structure.txt +++ b/repo_structure.txt @@ -6,6 +6,7 @@ │ ├── Images │ └── hacktober.png ├── LICENSE +├── PROJECT_STRUCTURE.md ├── README.md ├── Research-Nexas - Application Architecture.png ├── backend/