diff --git a/.github/ISSUE_TEMPLATE/gssoc23.md b/.github/ISSUE_TEMPLATE/gssoc23.md new file mode 100644 index 0000000..bce5148 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/gssoc23.md @@ -0,0 +1,23 @@ +--- +name: gssoc23 +about: Issue template for GSSoC'23 contributors +title: '' +labels: gssoc23 +assignees: '' + +--- + +**Issue Description:** +[Describe the issue or feature request in detail. Provide a clear and concise explanation of what needs to be addressed or implemented.] + +**Expected Behavior:** +[Describe what should happen when the issue is resolved or the feature is implemented.] + +**Current Behavior:** +[Describe the current behaviour or any error messages encountered, if applicable.] + +**Additional Information:** +[Provide any additional information, screenshots, or logs that may be helpful in addressing the issue.] + +**Labels:** +[Add appropriate labels to categorize the issue, such as bug, enhancement, documentation, etc.] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..24ddada --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'daily' \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..ec58942 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,19 @@ + + +## Fixes Issue + + + + + +## Changes proposed + + + +## Screenshots + + + +## Note to reviewers + + diff --git a/.github/workflows/auto-comment.yml b/.github/workflows/auto-comment.yml new file mode 100644 index 0000000..4936654 --- /dev/null +++ b/.github/workflows/auto-comment.yml @@ -0,0 +1,51 @@ +name: Auto Comment +on: + issues: + types: + - opened + - closed + - assigned + pull_request: + types: + - opened + - closed + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Auto Comment on Issues Opened + uses: wow-actions/auto-comment@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + issuesOpened: | + πŸ‘‹ @{{ author }} + + Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. + + Please make sure you have given us as much context as possible. + + - name: Auto Comment on Pull Request Merged + uses: wow-actions/auto-comment@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + pullRequestMerged: | + πŸ‘‹ @{{ author }} πŸŽ‰ Congrats on your merged pull request! Thanks for the valuable contribution! πŸ‘πŸŽ‰ + + - name: Auto Comment on Pull Request Opened + uses: wow-actions/auto-comment@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + pullRequestOpened: | + HelloπŸ‘‹ @{{ author }}, I hope you are doing well! +
+ Thank you for raising your pull request and contributing to our Community πŸŽ‰ + + Please make sure you have followed our contributing guidelines. We will review it as soon as possible. + + - name: Auto Comment on Issues Assigned + uses: wow-actions/auto-comment@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + issuesAssigned: | + Hello @{{ author }}, thank you for raising an issue. πŸ™Œ I have assigned the issue to you. You can now start working on it. If you encounter any problems, please feel free to connect with us. πŸ‘ \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..7611fe9 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,77 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '43 3 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # πŸ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" \ No newline at end of file diff --git a/.github/workflows/keylabeler.yml b/.github/workflows/keylabeler.yml deleted file mode 100644 index 8b13789..0000000 --- a/.github/workflows/keylabeler.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.setup/install.sh b/.setup/install.sh new file mode 100644 index 0000000..276d466 --- /dev/null +++ b/.setup/install.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +printf "Cloning The Repository...\n" +git clone https://github.com/sahil-sagwekar2652/GitHub-Automation-scripts.git +cd ../scripts +touch github_secrets.py +echo 'Please enter your Github Username' +read github_account +echo -e '\n Please enter your Github Password' +read github_password +echo -e "GITHUB_API_TOKEN = '$github_account'\nUSERNAME = '$github_password'" > github_secrets.py +cd .. +echo 'export PATH=$PATH''":'"$(pwd)"'/scripts''"' >> ~/.bash_profile \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..3c14272 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,35 @@ +# Code of Conduct + +We are committed to providing a friendly, inclusive, and safe environment for all participants in our project repository. This code of conduct outlines our expectations for behavior and ensures that everyone can collaborate in a positive and respectful manner. By participating in this project, you agree to abide by this code of conduct. + +## 1. Be Respectful and Inclusive + +Treat all participants with respect and courtesy, regardless of their race, ethnicity, nationality, gender identity, sexual orientation, age, disability, religion, or any other personal characteristics. Create an inclusive and welcoming environment for everyone to contribute. + +## 2. Foster a Collaborative Atmosphere + +Encourage open and constructive discussions. Be receptive to different ideas and perspectives. Avoid personal attacks, harassment, or any form of offensive or derogatory language or behavior. + +## 3. Be Mindful of Language and Tone + +Use clear and inclusive language when communicating in discussions, comments, and documentation. Be mindful of how your words may be perceived by others. Refrain from using offensive, discriminatory, or inflammatory language. +## 4. Exercise Empathy and Understanding + +Take into account that participants may have different backgrounds and experiences. Be considerate and understanding when communicating with others. If a misunderstanding occurs, seek to resolve it in a peaceful and respectful manner. + +## 5. Respect Privacy and Confidentiality + +Respect the privacy and confidentiality of others. Do not share personal information without consent. Be cautious when handling sensitive data and ensure compliance with relevant privacy laws and regulations. + +## 6. Report Incidents + +If you witness or experience any behavior that violates this code of conduct, promptly report it to the project maintainers or administrators. Provide as much detail as possible to help in the investigation. All reports will be handled confidentially and with discretion. + +## 7. Enforcement + +Violation of this code of conduct may result in temporary or permanent restrictions on participation in the project repository. Project maintainers and administrators reserve the right to enforce this code of conduct and take appropriate actions to address any misconduct or breaches of conduct. + + +## 8. Acknowledgment + +We value and appreciate everyone's contributions to our project repository. By following this code of conduct, we can create a supportive and inclusive environment where collaboration and growth thrive. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc60a2b..cc7b045 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,11 @@ # Contributing to GitHub-Automation-Scripts - -First off, thanks for taking the time to contribute! ❀️ - -All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. πŸŽ‰ +Ah, thank you ever so much for gracing us with your oh-so-valuable contributions! We're just thrilled to have you here. +But wait, hold on! Don't just dive in and contribute your precious time. First, read the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. πŸŽ‰ > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: > - Star the project > - Tweet about it - +Remember, every bit of support, big or small, makes a significant difference, and we truly appreciate every gesture of encouragement you offer. Your appreciation fuels our passion for the project, and we're immensely grateful for your involvement in any form! ❀️🌟🐦 ## Table of Contents @@ -18,25 +16,62 @@ All types of contributions are encouraged and valued. See the [Table of Contents ## Asking Questions -If you want to ask a question, join the 'contributing' slack channel of the Project. Click [here](https://join.slack.com/t/githubautomat-9t49360/shared_invite/zt-1v05p5kao-UBmelVfZd6EBjGuzd_6XYg) to join the workspace on Slack. +If you want to ask a question, join the 'GitHub Automation scripts' project channel on the GSSoC discord server. To join the project channel, make sure you have the 'GitHub Automation scripts' & 'Contributor' role assigned to you. If you don't have the role assigned to you, you can self-assign it in the [#self-roles](https://discord.com/channels/1099745007172329592/1099745007675646046) channel. Before you ask a question, it is best to search for existing [Issues](https://github.com/sahil-sagwekar2652/GitHub-Automation-scripts.git/issues) that might help you. It is also advisable to search the internet for answers first. -If you then still feel the need to ask a question and need clarification, we recommend the following: +If you still feel the need to ask a question and need clarification, we recommend the following: - Provide as much context as you can about what you're running into. -- Provide details about the your OS and environment. +- Provide details about your OS and environment. ## How To Contribute -- Fork the project on GitHub, clone it on your PC. +To start contributing, follow the guidelines given below: + +### 1. Fork the Repository +Fork the repository (https://github.com/sahil-sagwekar2652/GitHub-Automation-scripts) + +### 2. Clone the forked Repository +``` +git clone https://github.com//GitHub-Automation-scripts.git +``` +***NOTE*** - If you have an idea for an enhancement or a bug you can first check the [Issues](https://github.com/sahil-sagwekar2652/GitHub-Automation-scripts.git/issues) to see if your question has been asked before. + - If you'd like to work on an issue, please ask the creator of the issue to assign it to you. This helps to keep the workflow streamlined. -- **Make sure to push your code to the ```contributing``` branch.** -- Make sure to make the appropriate changes in the README.md file if you are adding a new script or feature. +### 3. Create a New Branch +``` +git checkout -b +``` +## Making Changes +Perform your desired changes to the code base. -## Styleguides +### 4. Track Changes +``` +git add . +``` +### 5. Commit Changes +``` +git commit -m "Suitable message" +``` + +### 6. Push Changes +``` +git push -u origin +``` + +## Creating a Pull Request +To create a pull request: + +- The pull request should mention the issue it is trying to solve and should be linked to it. Here is a video on how to link PRs to issues - [video link](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword). + +- Make sure to make the appropriate changes in the README.md file if you are adding a new script or feature. +- Add an appropriate title and description to your pull request, explaining your changes with suitable explanations and screenshots πŸ“πŸ–ΌοΈ +- Click on "Create Pull Request" to submit your contribution for review βœ… + +## Styleguides This project uses the Flake8 linter to lint the Python code. If you are using VSCode, I would suggest installing the [Flake8 linter extension](https://marketplace.visualstudio.com/items?itemName=ms-python.flake8) for VSCode. \ No newline at end of file diff --git a/README.md b/README.md index 3a04340..5a7ee45 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,50 @@ # GitHub Automation Scripts πŸ€– ![](https://github.com/sahil-sagwekar2652/GitHub-Automation-scripts/workflows/Flake8Linter/badge.svg) -This repository hosts scripts written in bash script and python to automate common Git/GitHub workflows. Normally to connect a local repository to GitHub one has to go to the GitHub website, create a new respository and then add the new GitHub repo as a remote for your local repository. The [create_repo](scripts/create_repo) script automates this process. +This repository hosts scripts written in bash and python to automate common Git/GitHub workflows. Normally to connect a local repository to GitHub one has to go to the GitHub website, create a new respository and then add the new GitHub repo as a remote for your local repository. The [create_repo](scripts/create_repo) script automates this process. [![GitHub-Automation-scripts](https://github-readme-stats.vercel.app/api/pin/?username=sahil-sagwekar2652&repo=GitHub-Automation-scripts&theme=dark)](https://github.com/sahil-sagwekar2652/GitHub-Automation-scripts)
- +## Status +
+ + + +
+ + + + + + + + + +
+
+ +## Table of Content +- [Tech](#tech) +- [Installation](#installation) +- [How to use](#how-to-use) +- [Development](#develop) +- [License](#license) + + ## Tech πŸ–₯️ [![My Skills](https://skillicons.dev/icons?i=py,bash,git,github&perline=4)](https://skillicons.dev) + +## πŸ—οΈ Installation + +## Getting Started + +To install and configure the project on your system locally, use the command mentioned below: + +```curl https://raw.githubusercontent.com/sahil-sagwekar2652/GitHub-Automation-scripts/main/.setup/install.sh | bash``` + ## Installation + ##### Requirements: - [Git Bash](https://git-scm.com/downloads) installed on your computer. - **GitHub personal access token**. (Go to your GitHub profile -> Settings -> Developer settings -> Personal Access Tokens -> Create new token with all the repository permissions) @@ -71,18 +106,36 @@ create_repo . test-repo ``` The result is a local respository is created with a connected remote repository automatically! - + ## πŸ‘¨β€πŸ’» Development -- Join the project workspace on +- Steps to join the project channel on + - Go to the [#self-roles](https://discord.com/channels/1099745007172329592/1099745007675646042) channel and choose the 'contributor' and 'GitHub-Automation-scripts' roles. + - You will be automatically added to the exclusive project channel. + - It will be the primary channel for all the discussions related to the project. + - Checkout the issues tab to find ideas! - Want to contribute? Great! -Make sure to go through the [Contributor's Guide](CONTRIBUTING.md). Trust me it wont take long ;) +Make sure to go through the [Contributor's Guide](CONTRIBUTING.md). Trust me it wont take long ;). + + +## πŸͺͺ License + +[![License](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)](LICENSE) + + +This project is licensed under the MIT license. For more information, please refer to the LICENSE file. + +We hope you find these automation scripts helpful in streamlining your Git and GitHub workflows + + -- ### **Make sure to push your code to the ```contributing``` branch.** +## Contributors -## License +

+ +

-[![Licence](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)](LICENSE) diff --git a/css/contributors.css b/css/contributors.css new file mode 100644 index 0000000..4de8649 --- /dev/null +++ b/css/contributors.css @@ -0,0 +1,62 @@ +@import 'http://github.com/service/https://fonts.googleapis.com/css?family=Permanent+Marker'; + +.contributors { + margin: 2rem 0; + padding: 0; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; +} + +.contributors h1 { + font: 5.5vw/1 Permanent Marker; + color: black; + font-size: 2.5rem; + margin-bottom: 2%; + display: inline-block; + opacity: 0.7; +} + +.contributors h1:hover { + opacity: 1; + text-decoration: underline; +} + +#contributor { + width: 85%; + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; +} + +.contributor-card { + width: 65px; + height: 65px; + margin: 5px; + clip-path: polygon(50% 0%, 91% 25%, 91% 75%, 50% 100%, 9% 75%, 9% 25%); +} + +.contributor-card img { + width: 100%; + height: 100%; + object-fit: cover; + transition: opacity 0.3s ease-in-out; +} + +.contributor-card img:hover { + width: 75px; + height: 75px; + opacity: 1; +} + +.contributor-card img:not(:hover) { + opacity: 0.8; +} + +.contributor-card:nth-child(4n+1), +.contributor-card:nth-child(4n+3) { + margin-top: -1.6rem; +} \ No newline at end of file diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..4b7b233 --- /dev/null +++ b/css/style.css @@ -0,0 +1,505 @@ +@import url('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@300&family=Open+Sans:wght@300;400;500;600;700&display=swap'); + +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: "Poppins", sans-serif; + text-decoration: none; +} + +html { + scroll-behavior: smooth; +} + + body { + display: flex; + flex-direction: column; + min-height: 100vh; + background: linear-gradient(to bottom, #ffffff, #ffffff); + } + + +/* Styling of Navbar */ +.navbar { + list-style: none; + z-index: 100; + font-family: 'Josefin Sans', sans-serif; + background: rgba(0, 130, 230, 0.6); + height: 80px; + width: 98%; + position: fixed; + top: 3%; + left: 1%; + transform: translate(-50%, -50%); + animation: moveAnimation 2s ease-in-out infinite alternate; +} +label.logo { + color: white; + font-size: 35px; + line-height: 80px; + padding: 0 70px; + font-weight: bold; +} +.navbar ul { + float: right; + margin-right: 20px; +} +.navbar ul li { + display: inline-block; + line-height: 80px; + margin: 0 5px; +} +.navbar ul li a { + color: white; + font-size: 17px; + text-transform: uppercase; + font-weight: bold; + padding: 7px 13px; + border-radius: 3px; +} +a.active, a:hover { + background: #1b9bff; + transition: 0.5s; +} +.checkbtn { + font-size: 30px; + color: white; + float: right; + line-height: 80px; + margin-right: 40px; + cursor: pointer; + display: none; +} +#check { + display: none; +} +@media (max-width: 1300px) { + label.logo { + font-size: 25px; + padding-left: 25px; + } + .navbar ul li a { + font-size: 16px; + } +} +@media (max-width: 1225px) { + .checkbtn { + display: block; + } + ul { + position: fixed; + width: 100%; + height: 100vh; + background-color: #2c3e50; + top: 80px; + left: -100%; + text-align: center; + transition: all .5s; + } + .navbar ul li { + display: block; + margin: 50px 0; + line-height: 30px; + } + .navbar ul li a { + font-size: 20px; + } + a:hover, a.active { + background: none; + color: #0082e6; + } + #check:checked ~ ul { + left: 0; + } +} +@keyframes moveAnimation { + 0% { + transform: translateY(-10px); + } + 100% { + transform: translateY(10px); + } +} + +/* End styling of navbar */ + + + /* View Port Style */ + + .Viewcontainer { + margin: 1.2rem 1.2rem; + display: flex; + justify-content: center; + align-items: center; + + } + + .icon { + transition: all 0.3s ease; + } + + .icon:hover { + transform: scale(1.2); + } + + .icon:hover ~ .icon { + transform: scale(0.8); + } + + /* ENDS----------->>>>>>> */ + + + + +/* Tabs Section Style */ + main { + flex: 1; + flex-wrap: wrap; + } + + .github-link { + display: flex; + align-items: center; + } + + .github-link a { + display: flex; + align-items: center; + text-decoration: none; + color: #333; + } + + .github-link a:hover { + color: #0366d6; + } + + .github-link i { + margin-right: 0.5rem; + } + + + #how-to-use p { + font-family: 'Open Sans', sans-serif; + font-weight: 700; + color: #333; + } + + code { + white-space: pre-wrap; + } + + #how-to-use code { + font-weight: 400; + background-color: #f5f5f5; + color: #333; + padding: 0.25rem 0.5rem; + border-radius: 4px; + } + +/* ENDS------->>>>>>>>>>>> */ + + +/* description Style */ + +.desc-container{ + display: flex; + flex-wrap: wrap; + flex-grow: 1; +} + + .description-section { + display: flex; + + flex-wrap: wrap; + justify-content: space-around; + align-items: center; + margin:2.4rem 2.4rem; + + } + + .description-section .image-container { + max-width: 900px; + } + + .description-section .image-container img { + padding: 2rem 2rem; + border-radius: 8px; + animation: floatAnimation 4s ease-in-out infinite alternate; + } + + .description-section .content-container { + + max-width: 600px; + + } + + .description-section .title { + font-family: 'Roboto', sans-serif; + font-size: 1.5rem; + font-weight: 700; + margin-bottom: 0.5rem; + color: #333; + } + + .description-section .description { + font-family: 'Roboto', sans-serif; + font-size: 1.2rem; + font-weight: 400; + color: #666; + } + + @keyframes floatAnimation { + 0% { + transform: translateY(-20px); + } + 100% { + transform: translateY(20px); + } + } + + /* ENDS--------->>>>>>>>> */ + + + /* Contribute Guid */ + .contribute-guide h1 { + font-family: 'Roboto', sans-serif; + font-size: 2xl; + font-weight: 700; + color: #333; + } + + .contribute-guide p { + font-family: 'Roboto', sans-serif; + font-size: 1rem; + font-weight: 400; + color: #666; + } + + .contribute-guide .link { + font-family: 'Roboto', sans-serif; + font-size: 1rem; + font-weight: 400; + color: #333; + text-decoration: underline; + } + +/* ENDS------->>>>>>>>>>>>> */ + + + + + +/* Footer Style */ + +footer { + margin-top: auto; + background-color: rgba(0, 130, 230, 0.75); + padding-top: 40px; + color: #fff; +} + +.footer-content { + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + text-align: center; +} + +.footer-content h3 { + font-size: 2.1rem; + font-weight: 500; + text-transform: capitalize; + line-height: 3rem; + margin-top: 10px; +} + +.footer-content p { + max-width: 500px; + margin: 10px auto; + line-height: 28px; + font-size: 14px; + color: #cacdd2; +} + +.socials{ + list-style: none; + display: flex; + align-items: center; + justify-content: center; + margin: 1rem 0 3rem 0; +} + +.socials li{ + margin: 0 10px; +} + +.socials a{ + text-decoration: none; + color: #fff; + border: 1.1px solid white; + padding: 10px; + font-size: 1.2rem; + border-radius: 50%; + transition: all .3s ease; +} + +.socials a i{ + font-size: 1.1rem; + width: 40px; + transition: color .4s ease; +} + +.socials a:hover i{ + color: aqua; +} + +.footer-bottom{ + background: transparent; + padding-top: 20px; + padding-bottom: 30px; + text-align: center; +} + +.tweet:hover { + color: white; + background: rgb(0, 140, 255); +} + +.mail:hover { + color: salmon; + background: white; +} + +.git:hover { + color: black; + background: white; +} + +.in:hover { + color: #04669A; + background: white; +} + +.youtube:hover { + color: red; + background: white; +} + +@media (max-width:500px) { + .footer-menu ul{ + display: flex; + margin-top: 10px; + margin-bottom: 20px; + } +} + +/* ENDS ------------->>>>>>>>> */ + +/* Scroll Button Style */ + +#scroll { + position: fixed; + bottom: 20px; + right: 10px; + height: 55px; + width: 55px; + display: none; + place-items: center; + border-radius: 50%; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + cursor: pointer; +} + +#scroll:hover { + box-shadow: 0 0 150px 10px #0366d6; +} + +#scroll-bar { + display: block; + height: calc(100% - 10px); + width: calc(100% - 10px); + background-color: #c3ddfa; + border-radius: 50%; + display: grid; + place-items: center; + font-size: 28px; + color: #001a2e; +} + +.pulse { + margin: 0 auto; + border-radius: 100px; + position: absolute; + left: -5.2px; + top: -5.2px; + z-index: 0; + background-color: transparent; + opacity: 0; + width: 66px; + height: 66px; + border: 6px solid #0366d6; + -webkit-border-radius: 100px; + -moz-border-radius: 100px; + -o-border-radius: 100px; + -ms-border-radius: 100px; + border-radius: 100px; + -webkit-animation: pulse 1s linear infinite 0.3s; + -moz-animation: pulse 1s linear infinite 0.3s; + border-image: initial; +} + +@-webkit-keyframes pulse { + 0% { + -webkit-transform: scale(0); + opacity: 0; + } + + 8% { + -webkit-transform: scale(0); + opacity: 0; + } + + 15% { + -webkit-transform: scale(0.1); + opacity: 1; + } + + 30% { + -webkit-transform: scale(0.5); + opacity: 1; + } + + 100% { + opacity: 0; + -webkit-transform: scale(1.5); + } +} + +@-moz-keyframes pulse { + 0% { + -webkit-transform: scale(0); + opacity: 0; + } + + 8% { + -webkit-transform: scale(0); + opacity: 0; + } + + 15% { + -webkit-transform: scale(0.1); + opacity: 1; + } + + 30% { + -webkit-transform: scale(0.5); + opacity: 1; + } + + 100% { + opacity: 0; + -webkit-transform: scale(1.5); + } +} \ No newline at end of file diff --git a/graphics/back.jpg b/graphics/back.jpg new file mode 100644 index 0000000..201a06a Binary files /dev/null and b/graphics/back.jpg differ diff --git a/graphics/repo.jpg b/graphics/repo.jpg new file mode 100644 index 0000000..2ea07ff Binary files /dev/null and b/graphics/repo.jpg differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..832016b --- /dev/null +++ b/index.html @@ -0,0 +1,233 @@ + + + + + + + + + + GitHub Automation Scripts πŸ€– + + + + + +
+
+
+ Image Description +
+
+

About GitHub Automation Scripts

+

Bash and Python scripts to automate your Git & GitHub workflow. Made by using only standard python libraries.

+ +
+

Tech Stack

+
+ Python + Bash + Git + GitHub +
+
+
+
+
+ +
+
+
+ gitrepo-Floating-Image +
+
+

GitHub Automation Scripts πŸ€–

+

All types of contributions are encouraged and valued. See the Table of Contents for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. πŸŽ‰

+ + + GitHub + +
+
+
+ + +
+
+

Contributing to GitHub-Automation-Scripts

+

First off, thanks for taking the time to contribute! ❀️

+

All types of contributions are encouraged and valued. See the Table of Contents for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. πŸŽ‰

+
+

And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:

+
    +
  • Star the project
  • +
  • Tweet about it
  • +
+
+ +

Table of Contents

+ + +

Asking Questions

+

If you want to ask a question, join the 'GitHub Automation scripts' project channel on the GSSoC discord server. To join the project channel, make sure you have the 'GitHub Automation scripts' & 'Contributor' role assigned to you. If you don't have the role assigned to you, you can self-assign it in the #self-roles channel.

+

Before you ask a question, it is best to search for existing Issues that might help you. It is also advisable to search the internet for answers first.

+

If you then still feel the need to ask a question and need clarification, we recommend the following:

+
    +
  • Provide as much context as you can about what you're running into.
  • +
  • Provide details about your OS and environment.
  • +
+ +

How To Contribute

+
    +
  • Fork the project on GitHub, clone it on your PC.
  • +
  • If you have an idea for an enhancement or a bug, you can first check the Issues to see if your question has been asked before.
  • +
  • If you'd like to work on an issue, please ask the creator of the issue to assign it to you. This helps to keep the workflow streamlined.
  • +
  • Create a new branch for your contribution and make the changes you want to make. (Always check for updates on the main branch before creating a pull request to avoid merge conflicts.)
  • +
  • The pull request should mention the issue it is trying to solve and should be linked to it. Here is a video on how to link PRs to issues - video link.
  • +
  • Make sure to make the appropriate changes in the README.md file if you are adding a new script or feature.
  • +
+ +

Styleguides

+

This project uses the Flake8 linter to lint the Python code. If you are using VSCode, I would suggest installing the Flake8 linter extension for VSCode.

+
+
+ + + +
+ + +
+

Installation

+

Requirements:

+
    +
  • Git Bash installed on your computer.
  • +
  • GitHub personal access token. (Go to your GitHub profile -> Settings -> Developer settings -> Personal Access Tokens -> Create new token with all the repository permissions)
  • +
+

Note: This script is written exclusively for Git Bash on Windows. You will have to modify it for other shells.

+
    +
  1. +

    Fork and clone the repository locally.

    +
  2. +
  3. +

    Create a github_secrets.py file in the ./scripts folder and define the following variables inside it:

    +
    GITHUB_API_TOKEN = "Your GitHub personal access token"
    +USERNAME = "Your GitHub username"
    +
  4. +
  5. +

    Add the project path to the PATH variable (Recommended):

    +
    $ export PATH=$PATH":"$(pwd)"/scripts"
    +

    To permanently add the scripts path to the PATH variable, run the below command in the project's root directory. (This file is located in your home directory)

    +
    $ echo 'export PATH=$PATH''":'"$(pwd)"'/scripts''"' >> ~/.bash_profile
    +
  6. +
  7. +

    OR

    +

    Run the following commands in the project folder to add the scripts to your bin directory:

    +
    $ cp -r /scripts/* /usr/bin/
    +
  8. +
+
+ + + + +
+ +
+

Our Valuable Contributors

+
+
+ +
+ +
    +
  • +
  • +
  • +
  • +
  • +
+ +
+ +
+ 🠕 + +
+ + + + + + + + diff --git a/js/contributors.js b/js/contributors.js new file mode 100644 index 0000000..1297e0b --- /dev/null +++ b/js/contributors.js @@ -0,0 +1,53 @@ +const cont = document.getElementById('contributor'); + +async function fetchContributors(pageNumber) { + const perPage = 100; + const url = `https://api.github.com/repos/sahil-sagwekar2652/GitHub-Automation-scripts/contributors?page=${pageNumber}&per_page=${perPage}`; + + const response = await fetch(url); + if (!response.ok) { + throw new Error(`Failed to fetch contributors data. Status code: ${response.status}`); + } + + const contributorsData = await response.json(); + return contributorsData; +} + +// Function to fetch all contributors +async function fetchAllContributors() { + let allContributors = []; + let pageNumber = 1; + + try { + while (true) { + const contributorsData = await fetchContributors(pageNumber); + if (contributorsData.length === 0) { + break; + } + allContributors = allContributors.concat(contributorsData); + pageNumber++; + } + + // Display contributors in the honeycomb-like layout + allContributors.forEach((contributor) => { + const contributorCard = document.createElement('div'); + contributorCard.classList.add('contributor-card'); + + const avatarImg = document.createElement('img'); + avatarImg.src = contributor.avatar_url; + avatarImg.alt = `${contributor.login}'s Picture`; + + const loginLink = document.createElement('a'); + loginLink.href = contributor.html_url; + loginLink.appendChild(avatarImg); + + contributorCard.appendChild(loginLink); + + cont.appendChild(contributorCard); + }); + } catch (error) { + console.error(error); + } +} + +fetchAllContributors(); diff --git a/js/scripts.js b/js/scripts.js new file mode 100644 index 0000000..619ef53 --- /dev/null +++ b/js/scripts.js @@ -0,0 +1,41 @@ +function openTab(evt, tabName) { + var i, tabContent, tabLinks; + + tabContent = document.getElementsByClassName("tab-content"); + for (i = 0; i < tabContent.length; i++) { + tabContent[i].style.display = "none"; + } + + tabLinks = document.getElementsByTagName("button"); + for (i = 0; i < tabLinks.length; i++) { + tabLinks[i].classList.remove("bg-gray-300"); + tabLinks[i].classList.remove("active:bg-gray-300"); + } + + document.getElementById(tabName).style.display = "block"; + evt.currentTarget.classList.add("bg-gray-300"); + evt.currentTarget.classList.add("active:bg-gray-300"); +} + +// Functioning of the scroll up button + +let calcScrollValue = () => { + let scrollProgress = document.getElementById("scroll"); + let pos = document.documentElement.scrollTop; + let calcHeight = + document.documentElement.scrollHeight - + document.documentElement.clientHeight; + let scrollValue = Math.round((pos * 100) / calcHeight); + if (pos > 100) { + scrollProgress.style.display = "grid"; + } else { + scrollProgress.style.display = "none"; + } + scrollProgress.addEventListener("click", () => { + document.documentElement.scrollTop = 0; + }); + scrollProgress.style.background = `conic-gradient(#0366d6 ${scrollValue}%, #d7d7d7 ${scrollValue}%)`; +}; + +window.onscroll = calcScrollValue; +window.onload = calcScrollValue; diff --git a/scripts/Maven build script/README.md b/scripts/Maven build script/README.md new file mode 100644 index 0000000..2e022e1 --- /dev/null +++ b/scripts/Maven build script/README.md @@ -0,0 +1,37 @@ + +--- + +# Maven Build Script + +This script is designed to build and test a Maven project. It automates the process of cleaning the project, building the project, and running tests. It also provides feedback on the success or failure of each step. + +## Prerequisites + +Before running this script, ensure that you have the following prerequisites installed: + +- [Maven](https://maven.apache.org/) - The Apache Maven build tool. +- [Java Development Kit (JDK)](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) - The Java development kit required for building and running the project. + +## Usage + +To use this script, follow the steps below: + +1. Open a terminal or command prompt. +2. Navigate to the directory where the script is located. +3. Make the script executable, if necessary, using the command: `chmod +x build.sh` +4. Run the script using the command: `./build.sh` + +## Script Explanation + +The script performs the following steps: + +1. **Clean the Project**: The command `mvn clean` is executed to clean the project directory by removing any previously compiled files or artifacts. + +2. **Build the Project**: The command `mvn package` is executed to build the project. This step compiles the source code, runs any necessary tests, and packages the application into an executable artifact (e.g., JAR file). + +3. **Check Build Status**: The script checks the exit code of the previous command using `$?`. If the exit code is `0`, it indicates a successful build. The script displays the message "Build completed successfully." Otherwise, it displays the message "Build failed." and exits with status `1`. + +4. **Run Tests**: The command `mvn test` is executed to run any defined tests for the project. + +5. **Check Test Results**: Similar to the previous step, the script checks the exit code of the previous command. If the exit code is `0`, it indicates that all tests passed. The script displays the message "All tests passed." Otherwise, it displays the message "Some tests failed." and exits with status `1`. + diff --git a/scripts/Maven build script/maven_build.sh b/scripts/Maven build script/maven_build.sh new file mode 100644 index 0000000..c9c1ff8 --- /dev/null +++ b/scripts/Maven build script/maven_build.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Clean the project +mvn clean + +# Build the project +mvn package + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "Build completed successfully." +else + echo "Build failed." + exit 1 +fi + +# Run tests +mvn test + +# Check if tests passed +if [ $? -eq 0 ]; then + echo "All tests passed." +else + echo "Some tests failed." + exit 1 +fi + +# Additional steps can be added here, such as generating documentation or creating artifacts + +# If everything succeeded, the built artifacts can be found in the target/ + +#Save this script in a file named build.sh, and make sure to provide the necessary permissions to execute the script by running chmod +x build.sh in the terminal. + +#To execute the script, navigate to the directory containing the script file (build.sh) in the terminal and run ./build.sh. + +#Make sure you have Maven installed and configured correctly in your environment before running this script. Adjust the script or include additional steps as needed based on your project's requirements. diff --git a/scripts/create_issue.py b/scripts/create_issue.py new file mode 100644 index 0000000..290fc56 --- /dev/null +++ b/scripts/create_issue.py @@ -0,0 +1,61 @@ +# Create Issue by Python + +import argparse +import requests +import json + +# Parse command-line arguments +parser = argparse.ArgumentParser(description='Create a GitHub issue') +parser.add_argument('owner', type=str, help='Repository owner') +parser.add_argument('repo', type=str, help='Repository name') +parser.add_argument('title', type=str, help='Issue title') +parser.add_argument('description', type=str, help='Issue description') +parser.add_argument('token', type=str, help='GitHub API token') +args = parser.parse_args() + +# Get the command-line arguments +owner = args.owner +repo = args.repo +title = args.title +description = args.description +token = args.token + +# Set the GitHub API endpoint for creating an issue +url = f"https://api.github.com/repos/%7Bowner%7D/%7Brepo%7D/issues" + +# Set the headers with the API token for authentication +headers = { + 'Authorization': f'token {token}', + 'Accept': 'application/vnd.github.v3+json' +} + +# Set the issue data +data = { + "title": title, + "body": description +} + +# Send a POST request to create the issue +response = requests.post(url, headers=headers, json=data) + +# Check the response status code +if response.ok: + # Issue created successfully + issue_data = response.json() + issue_number = issue_data.get('number') + issue_url = issue_data.get('html_url') + print("Issue created successfully!") + print(f"Issue number: {issue_number}") + print(f"Issue URL: {issue_url}") +else: + # Issue creation failed + error_message = response.json().get('message', 'Unknown error') + error_status = response.status_code + error_response = json.dumps(response.json(), indent=4) + print(f"Failed to create issue. Error status: {error_status}") + print(f"Error message: {error_message}") + print("Error response:") + print(error_response) + +print("Thank you!") +# Issue Created diff --git a/scripts/create_pull_request.sh b/scripts/create_pull_request.sh new file mode 100644 index 0000000..3ea0930 --- /dev/null +++ b/scripts/create_pull_request.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Set your GitHub access token and repository details +TOKEN="YOUR_GITHUB_ACCESS_TOKEN" +REPO_OWNER="OWNER" +REPO_NAME="REPO_NAME" +BASE_BRANCH="base_branch" # The branch you want to merge into +HEAD_BRANCH="head_branch" # The branch you want to merge from +PR_TITLE="Pull Request Title" +PR_BODY="Pull Request Body" + +# Method 1: Using GitHub API with cURL +create_pull_request_with_curl() { + # Create a pull request using GitHub API + pull_request=$(curl -X POST -H "Authorization: token $TOKEN" \ + -d '{"title": "'"$PR_TITLE"'", "body": "'"$PR_BODY"'", "head": "'"$REPO_OWNER:$HEAD_BRANCH"'", "base": "'"$BASE_BRANCH"'"}' \ + "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls") + + # Extract the pull request number from the response + pr_number=$(echo "$pull_request" | jq -r '.number') + + # Check if the pull request was successfully created + if [ -n "$pr_number" ] && [ "$pr_number" != "null" ]; then + echo "Pull request created successfully using cURL. PR Number: $pr_number" + else + echo "Failed to create pull request using cURL. Error message:" + echo "$pull_request" | jq -r '.message' + fi +} + +# Method 2: Using hub command-line tool +create_pull_request_with_hub() { + # Install hub if not already installed + if ! command -v hub &> /dev/null; then + echo "hub command-line tool is not installed. Installing..." + sudo apt-get update + sudo apt-get install hub -y + fi + + # Create a pull request using hub + hub pull-request -b "$REPO_OWNER:$BASE_BRANCH" -h "$REPO_OWNER:$HEAD_BRANCH" -m "$PR_TITLE" -m "$PR_BODY" +} + +# Method 3: Using gh command-line tool +create_pull_request_with_gh() { + # Install gh if not already installed + if ! command -v gh &> /dev/null; then + echo "gh command-line tool is not installed. Installing..." + sudo apt-get update + sudo apt-get install gh -y + fi + + # Create a pull request using gh + gh pr create --base "$BASE_BRANCH" --head "$HEAD_BRANCH" --title "$PR_TITLE" --body "$PR_BODY" +} + +# Execute the desired method to create a pull request +# Uncomment the method you want to use, and comment out the others + +# Method 1: Using GitHub API with cURL +# create_pull_request_with_curl + +# Method 2: Using hub command-line tool +# create_pull_request_with_hub + +# Method 3: Using gh command-line tool +# create_pull_request_with_gh diff --git a/scripts/create_repo b/scripts/create_repo index 968053b..32a5c4e 100644 --- a/scripts/create_repo +++ b/scripts/create_repo @@ -1,58 +1,2 @@ -#!/usr/bin/env python - -import argparse -import os -import http.client -import json -from github_secrets import GITHUB_API_TOKEN, USERNAME - -if not GITHUB_API_TOKEN: - raise ValueError("Please set the environment variable GITHUB_API_TOKEN in the github_secrets.py file") # noqa: E501 - -URL = "https://api.github.com/user/repos" - -parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository') # noqa: E501 - -parser.add_argument('path', - metavar='PATH', - type=str, - help='Enter the path for the new repository') -parser.add_argument('name', - metavar='NAME', - type=str, - help='Enter a name for the new repository') -args = parser.parse_args() - -name = args.name -path = args.path - -os.chdir(path) -os.mkdir(name) -os.chdir(name) -os.system('git init -b main') -os.system('touch README.md') -os.system('git add . && git commit -m "initial commit"') -# os.system('git status') - -conn = http.client.HTTPSConnection("api.github.com") -payload = json.dumps({ - "name": name, - "description": "made with the GitHub API" -}) -headers = { - 'Authorization': f'Bearer {GITHUB_API_TOKEN}', - 'Content-Type': 'application/json', - 'User-Agent': f'{USERNAME}' -} - -conn.request("POST", "/user/repos", payload, headers) -res = conn.getresponse() -data = res.read().decode("utf-8") -response = json.loads(data) - -print(response) -remote_url = response['svn_url'] - -os.system(f'git remote add origin {remote_url}') -os.system('git push origin main') -print(f"\nREMOTE URL FOR \"{name}\" is: {remote_url}") +#!/bin/bash +python create_repo.py "$@" diff --git a/scripts/create_repo.py b/scripts/create_repo.py new file mode 100644 index 0000000..1dfee59 --- /dev/null +++ b/scripts/create_repo.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +''' +This script is used to create a local repository linked with a remote repository. +''' + +# Imports the required modules +import argparse # required for parsing the command line arguments passed to the script +import os # required for creating the directory and changing the directory and running the git commands # noqa: E501 +import http.client # required for making the http request +import json # required for parsing the response received from the http request +from github_secrets import GITHUB_API_TOKEN, USERNAME # required for authenticating the http request and setting the user agent # noqa: E501 + + +# Checks if the environment variables are set or not. If not, raises an error as ValueError. # noqa: E501 +# Environment variables are set in the github_secrets.py file which contains the GITHUB_API_TOKEN and USERNAME # noqa: E501 +# The GITHUB_API_TOKEN is the personal access token generated from the GitHub account. # noqa: E501 +if not GITHUB_API_TOKEN: + raise ValueError("Please set the environment variable GITHUB_API_TOKEN in the github_secrets.py file") # noqa: E501 + +# Base URL for the GitHub API which is used to create a new repository # noqa: E501 +URL = "https://api.github.com/user/repos" + +# Creates a parser object of the argparse class +# The parser object is used to parse the command line arguments passed to the script # noqa: E501 +# The parser object is used to create the help text for the script # noqa: E501 +parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository') # noqa: E501 + +# Adds the arguments to the parser object +parser.add_argument('path', # This argument can be accessed using the `path` variable # noqa: E501 + metavar='PATH', + type=str, + help='Enter the path for the new repository') +parser.add_argument('name', # This argument can be accessed using the `name` variable # noqa: E501 + metavar='NAME', + type=str, + help='Enter a name for the new repository') +args = parser.parse_args() # parses the arguments passed to the script. The arguments are stored in the `args` variable # noqa: E501 + +name = args.name # stores the name of the repository from `args` in the name variable +path = args.path # stores the path of the repository from `args` in the path variable + + +# The following codes creates a new directory with the name of the repository and initializes it with git using the `os` module # noqa: E501 +os.chdir(path) # changes the directory to the path specified in the `path` variable # noqa: E501 +os.mkdir(name) # creates a new directory with the name specified in the `name` variable # noqa: E501 +os.chdir(name) # changes the directory to the newly created directory # noqa: E501 +os.system('git init -b main') # This executes 'git init -b main' as a system command as if it were written in git bash. It initializes the directory with git and sets the default branch to `main` # noqa: E501 +os.system('touch README.md') # creates a README.md file # noqa: E501 +os.system('git add . && git commit -m "initial commit"') # adds the newly created README.md file to the staging area and commits it with the message# noqa: E501 + + +# The following code makes a POST request to the GitHub API to create a new repository # noqa: E501 +conn = http.client.HTTPSConnection("api.github.com") # creates a connection object +# The payload is the data that is sent +payload = json.dumps({ + "name": name, + "description": "made with the GitHub API" +}) + +# Metadata that is sent along with the request +# The metadata contains the authorization token, the content type and the user agent # noqa: E501 +headers = { + 'Authorization': f'Bearer {GITHUB_API_TOKEN}', + 'Content-Type': 'application/json', + 'User-Agent': f'{USERNAME}' +} + +# The request is made to the URL with the payload and the headers +# The response received is stored in the `res` variable +# The response is read and decoded using utf-8 encoding and stored in the `data` variable +# The `data` variable is parsed using the json module and stored in the `response` variable # noqa: E501 +# The `response` variable contains the response received from the GitHub API, which is a JSON object # noqa: E501 +conn.request("POST", "/user/repos", payload, headers) +res = conn.getresponse() +data = res.read().decode("utf-8") +response = json.loads(data) + +print(response) +remote_url = response['svn_url'] # stores the remoteurl using the key `svn_url` in the `response` variable # noqa: E501 + +# Runs the git commands as system commands # noqa: E501 +os.system(f'git remote add origin {remote_url}') # adds the remote url to the local repository +os.system('git push origin main') # Pushes the local repository to the remote repository +print(f"\nREMOTE URL FOR \"{name}\" is: {remote_url}") # Prints the remote url diff --git a/scripts/create_repo.sh b/scripts/create_repo.sh new file mode 100644 index 0000000..4edc0c7 --- /dev/null +++ b/scripts/create_repo.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# GitHub Personal Access Token +TOKEN="YOUR_PERSONAL_ACCESS_TOKEN" + +# Repository name +REPO_NAME="new-repo" + +# Repository description +REPO_DESCRIPTION="This is a new repository" + +# API endpoint +API_URL="https://api.github.com/user/repos" + +# Create repository payload +PAYLOAD=$(cat << EOF +{ + "name": "$REPO_NAME", + "description": "$REPO_DESCRIPTION", + "private": false, + "auto_init": false +} +EOF +) + +# Send POST request to create repository +response=$(curl -s -H "Authorization: token $TOKEN" -d "$PAYLOAD" "$API_URL") + +# Check response status +if [[ "$(echo "$response" | jq -r '.message')" == "Validation Failed" ]]; then + echo "Error: Failed to create repository." + echo "Reason: $(echo "$response" | jq -r '.errors[0].message')" +else + echo "Repository '$REPO_NAME' created successfully." +fi diff --git a/scripts/delete_repo.sh b/scripts/delete_repo.sh new file mode 100644 index 0000000..2cd9500 --- /dev/null +++ b/scripts/delete_repo.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Prompt the user to enter the repository name +read -p "Enter the name of the repository to delete: " repo_name + +# Prompt for confirmation +read -p "Are you sure you want to delete the repository '$repo_name'? This action cannot be undone. (y/n): " confirm + +# Convert the confirmation input to lowercase +confirm=${confirm,,} + +# Check if the user confirmed the deletion +if [[ $confirm != "y" ]]; then + echo "Repository deletion canceled." + exit 0 +fi + +# Authenticate the user using personal access token (PAT) +# Replace with your actual personal access token +auth_header="Authorization: token " + +# Delete the repository using the GitHub API +response=$(curl -X DELETE -s -H "$auth_header" "https://api.github.com/repos/$repo_name") + +# Check the response status code +if [[ $(echo "$response" | jq -r '.message') == "Not Found" ]]; then + echo "Repository '$repo_name' not found." +elif [[ $(echo "$response" | jq -r '.message') == "Bad credentials" ]]; then + echo "Authentication failed. Please check your credentials." +elif [[ $(echo "$response" | jq -r '.message') == "Repository marked for deletion." ]]; then + echo "Repository '$repo_name' successfully deleted." +else + echo "An error occurred while deleting the repository." + echo "Response: $response" +fi diff --git a/scripts/fork_clone.py b/scripts/fork_clone.py new file mode 100644 index 0000000..a38eb8f --- /dev/null +++ b/scripts/fork_clone.py @@ -0,0 +1,69 @@ +# Fork and Clone by Python + +import argparse +import requests +import json +import os +from github_secrets import GITHUB_API_TOKEN + +# Parse command-line arguments +parser = argparse.ArgumentParser(description='Fork a repo') +parser.add_argument('owner', type=str, help='Repository owner') +parser.add_argument('repo', type=str, help='Repository name') +# parser.add_argument('token', type=str, help='GitHub API token') +parser.add_argument('name', type=str, help='Enter name for forked repo') +args = parser.parse_args() + +# Get the command-line arguments +owner = args.owner +repo = args.repo +# token = args.token +token = GITHUB_API_TOKEN +name = args.name + +# Set the GitHub API endpoint for forking a repo +url = f"https://api.github.com/repos/%7Bowner%7D/%7Brepo%7D/forks" + +# Set the headers with the API token for authentication +headers = { + 'Authorization': f'token {token}', + 'Accept': 'application/vnd.github.v3+json' +} + +# Set the fork repo name +data = { + "name" : name +} + +# Send a POST request to fork +response = requests.post(url, headers=headers, json=data) + +# Check the response status code +if response.ok: + # Forked successfully + fork_data = response.json() + print("Forked successfully!") + print(fork_data.get('clone_url')) +else: + # Fork failed + error_message = response.json().get('message', 'Unknown error') + error_status = response.status_code + error_response = json.dumps(response.json(), indent=4) + print(f"Failed to fork a repo. Error status: {error_status}") + print(f"Error message: {error_message}") + print("Error response:") + print(error_response) + +# Code to Clone +try: + cmd = "git clone {}".format(fork_data.get('clone_url')) + print("Starting to clone {}".format(fork_data.get('clone_url'))) + print("Running command '{}'".format(cmd)) + os.system(cmd) + print("Finshed cloning {}".format(fork_data.get('clone_url'))) + print("#####################################") + print("") + print("Thank you!") +except NameError: + print("Error cloning") +# Forked and cloned successfully diff --git a/scripts/push_repo.py b/scripts/push_repo.py new file mode 100644 index 0000000..ba084e4 --- /dev/null +++ b/scripts/push_repo.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import argparse +import os +from github_secrets import GITHUB_API_TOKEN + + +def parseArgs(): + parser = argparse.ArgumentParser(description='Push an existing local repository to a newly created remote repository of the same name') # noqa: E501 + parser.add_argument('path', + metavar='PATH', + type=str, + help='Enter the path for existing local repository') + parser.add_argument('url', + metavar='URL', + type=str, + help='Enter the newly created remote repository url (.git)') + parser.add_argument('description', + metavar='DESCRIPTION', + type=str, + help='Enter the description for remote repository') + args = parser.parse_args() + return args + + +def pushRepo(remote_url): + origin = remote_url[:8] + GITHUB_API_TOKEN + "@" + remote_url[8:] + os.system(f'git push {origin} --mirror') + + +def main(): + path = args.path + remote_url = args.url + + os.chdir(path) + if os.path.isdir('./.git') is False: + print("Not in a git directory") + exit() + + pushRepo(remote_url) + + +if __name__ == "__main__": + args = parseArgs() + main()