diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..6c883ec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,120 @@ +name: Bug Report +description: Report a bug or issue with one of the scripts +title: "[BUG] " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thank you for taking the time to report a bug! Please fill out the information below to help us resolve the issue quickly. + + - type: dropdown + id: script-name + attributes: + label: Script Name + description: Which script is experiencing the issue? + options: + - mass-privatize-repos.sh + - mass-publicize-repos.sh + - add-multiple-collaborators.sh + - bulk-clone.sh + - github-stats-report.sh + - mass-archive-inactive-repos.sh + - repo-detailed-report.sh + - repos-bulk-report.sh + - Other (please specify in description) + validations: + required: true + + - type: dropdown + id: operating-system + attributes: + label: Operating System + description: What operating system are you using? + options: + - macOS + - Linux (Ubuntu) + - Linux (Other) + - Windows (WSL) + - Windows (Git Bash) + - Other + validations: + required: true + + - type: input + id: shell-version + attributes: + label: Shell Version + description: What shell are you using? (e.g., bash 5.1, zsh 5.8) + placeholder: "bash 5.1" + validations: + required: true + + - type: textarea + id: bug-description + attributes: + label: Bug Description + description: A clear and concise description of what the bug is + placeholder: "Describe what happened..." + validations: + required: true + + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to Reproduce + description: Steps to reproduce the behavior + placeholder: | + 1. Run the script with command '...' + 2. Enter input '...' + 3. See error + validations: + required: true + + - type: textarea + id: expected-behavior + attributes: + label: Expected Behavior + description: What you expected to happen + placeholder: "I expected..." + validations: + required: true + + - type: textarea + id: actual-behavior + attributes: + label: Actual Behavior + description: What actually happened + placeholder: "Instead, what happened was..." + validations: + required: true + + - type: textarea + id: error-output + attributes: + label: Error Output + description: Any error messages or output from the script + placeholder: "Paste error messages here..." + render: shell + + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: Add any other context about the problem here + placeholder: "Any additional information..." + + - type: checkboxes + id: checklist + attributes: + label: Pre-submission Checklist + description: Please verify the following before submitting + options: + - label: I have the latest version of GitHub CLI installed + required: true + - label: I have jq installed and accessible + required: true + - label: I am authenticated with GitHub CLI (`gh auth status` works) + required: true + - label: I have searched existing issues to avoid duplicates + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..16335d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,95 @@ +name: Feature Request +description: Suggest a new script or feature for the collection +title: "[FEATURE] " +labels: ["enhancement"] +body: + - type: markdown + attributes: + value: | + Thank you for suggesting a new feature! Please provide as much detail as possible to help us understand your request. + + - type: dropdown + id: request-type + attributes: + label: Request Type + description: What type of feature are you requesting? + options: + - New script + - Enhancement to existing script + - Documentation improvement + - Workflow/CI improvement + - Other + validations: + required: true + + - type: input + id: script-name + attributes: + label: Script Name (if applicable) + description: If this is about an existing script, which one? + placeholder: "e.g., mass-privatize-repos.sh" + + - type: textarea + id: feature-description + attributes: + label: Feature Description + description: A clear and concise description of what you want to happen + placeholder: "I would like..." + validations: + required: true + + - type: textarea + id: use-case + attributes: + label: Use Case + description: Describe the specific use case or problem this feature would solve + placeholder: "This would help when..." + validations: + required: true + + - type: textarea + id: proposed-solution + attributes: + label: Proposed Solution + description: How do you think this feature should work? + placeholder: "The script could..." + + - type: textarea + id: alternatives + attributes: + label: Alternatives Considered + description: Have you considered any alternative solutions or workarounds? + placeholder: "I have tried..." + + - type: textarea + id: example-usage + attributes: + label: Example Usage + description: Provide an example of how this feature would be used + placeholder: | + ```bash + ./new-script.sh + # Expected prompts and outputs + ``` + render: shell + + - type: dropdown + id: priority + attributes: + label: Priority + description: How important is this feature to you? + options: + - Low - Nice to have + - Medium - Would be helpful + - High - Important for my workflow + - Critical - Blocking my work + + - type: checkboxes + id: contribution + attributes: + label: Contribution + description: Are you willing to help implement this feature? + options: + - label: I would be willing to implement this feature myself + - label: I would be willing to help test this feature + - label: I would be willing to help with documentation diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..eeb974b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,98 @@ +name: Pull Request +description: Pull Request Template +title: "" +body: + - type: markdown + attributes: + value: | + Thank you for contributing to the GitHub Scripts Collection! Please fill out the information below. + + - type: dropdown + id: pr-type + attributes: + label: Type of Change + description: What type of change does this PR introduce? + multiple: true + options: + - Bug fix (non-breaking change that fixes an issue) + - New feature (non-breaking change that adds functionality) + - Breaking change (fix or feature that would cause existing functionality to not work as expected) + - Documentation update + - Code refactoring + - Performance improvement + - Security fix + validations: + required: true + + - type: textarea + id: description + attributes: + label: Description + description: Please describe your changes in detail + placeholder: "This PR..." + validations: + required: true + + - type: textarea + id: motivation + attributes: + label: Motivation and Context + description: Why is this change required? What problem does it solve? + placeholder: "This change is needed because..." + + - type: input + id: related-issues + attributes: + label: Related Issues + description: Link any related issues (e.g., "Fixes #123" or "Closes #456") + placeholder: "Fixes #" + + - type: textarea + id: testing + attributes: + label: Testing + description: Please describe how you tested your changes + placeholder: | + - [ ] Tested on macOS + - [ ] Tested on Linux + - [ ] Tested with various inputs + - [ ] Tested error scenarios + validations: + required: true + + - type: textarea + id: screenshots + attributes: + label: Screenshots (if applicable) + description: Add screenshots to help explain your changes + placeholder: "Paste screenshots here or remove this section if not applicable" + + - type: checkboxes + id: checklist + attributes: + label: Checklist + description: Please verify all items before submitting + options: + - label: My code follows the project's coding standards + required: true + - label: I have performed a self-review of my code + required: true + - label: I have commented my code, particularly in hard-to-understand areas + required: true + - label: I have made corresponding changes to the documentation + required: false + - label: My changes generate no new warnings or errors + required: true + - label: I have added tests that prove my fix is effective or that my feature works + required: false + - label: New and existing unit tests pass locally with my changes + required: false + - label: Any dependent changes have been merged and published + required: false + + - type: textarea + id: additional-notes + attributes: + label: Additional Notes + description: Any additional information about this PR + placeholder: "Add any other context about the pull request here" diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 0000000..c77d6e3 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,84 @@ +name: Code Quality Check + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + shellcheck: + name: Shell Script Analysis + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + scandir: '.' + format: gcc + severity: warning + + script-validation: + name: Script Validation + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Install GitHub CLI + run: | + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg + sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + sudo apt update + sudo apt install gh + + - name: Validate script syntax + run: | + echo "Checking shell script syntax..." + for script in *.sh; do + if [ -f "$script" ]; then + echo "Checking $script..." + bash -n "$script" || exit 1 + echo "✓ $script syntax is valid" + fi + done + + - name: Check script permissions + run: | + echo "Checking script permissions..." + for script in *.sh; do + if [ -f "$script" ] && [ ! -x "$script" ]; then + echo "❌ $script is not executable" + exit 1 + elif [ -f "$script" ]; then + echo "✓ $script has correct permissions" + fi + done + + - name: Validate dependencies check + run: | + echo "Validating dependency checks in scripts..." + for script in *.sh; do + if [ -f "$script" ]; then + echo "Checking $script for dependency validation..." + if ! grep -q "command -v gh" "$script"; then + echo "❌ $script doesn't check for GitHub CLI dependency" + exit 1 + fi + if ! grep -q "command -v jq" "$script"; then + echo "⚠️ $script might be missing jq dependency check" + fi + echo "✓ $script has proper dependency checks" + fi + done diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..1a1a5fd --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,182 @@ +# Contributing to GitHub Scripts Collection + +Thank you for your interest in contributing to this project! We welcome contributions from the community and appreciate your help in making this collection of GitHub automation tools better. + +## 🚀 How to Contribute + +### 1. Fork the Repository +- Click the "Fork" button at the top right of this repository +- Clone your fork to your local machine: + ```bash + git clone https://github.com/NoroSaroyan/github-scripts.git + cd github-scripts + ``` + +### 2. Create a Feature Branch +- Create a new branch for your feature or bug fix: + ```bash + git checkout -b feature/your-feature-name + # or + git checkout -b fix/issue-description + ``` + +### 3. Make Your Changes +- Write your code following our coding standards (see below) +- Test your changes thoroughly +- Ensure your script works on different platforms if applicable + +### 4. Commit Your Changes +- Write clear, descriptive commit messages: + ```bash + git add . + git commit -m "Add feature: description of your changes" + ``` + +### 5. Push and Create a Pull Request +- Push your branch to your fork: + ```bash + git push origin feature/your-feature-name + ``` +- Go to the original repository and click "New Pull Request" +- Fill out the pull request template with detailed information + +## 📋 Coding Standards + +### Script Requirements +All new scripts must: + +1. **Start with a proper shebang**: `#!/bin/bash` +2. **Include error handling**: Check for required dependencies and validate inputs +3. **Use consistent formatting**: Follow the existing code style +4. **Include user-friendly prompts**: Clear instructions and interactive elements +5. **Handle edge cases**: Validate inputs and provide meaningful error messages + +### Code Style Guidelines + +```bash +# Good: Clear variable names and proper error checking +if ! command -v gh &>/dev/null; then + echo "Error: GitHub CLI (gh) is required but not installed." + exit 1 +fi + +# Good: User-friendly prompts with defaults +read -rp "Enter GitHub username: " USERNAME +read -rp "Enter permission level (pull/push/admin), default 'push': " PERM +PERM=${PERM:-push} + +# Good: Input validation +if [[ -z "$USERNAME" ]]; then + echo "Error: Username cannot be empty." + exit 1 +fi +``` + +### Documentation Requirements + +Each new script must include: + +1. **Header comment** explaining what the script does +2. **Usage examples** in comments +3. **Dependencies** clearly listed +4. **Error handling** for common failure scenarios + +## 🧪 Testing + +Before submitting a pull request: + +1. **Test your script** with various inputs and edge cases +2. **Verify compatibility** with both macOS and Linux (if applicable) +3. **Check error handling** by providing invalid inputs +4. **Ensure dependencies** are properly checked + +### Test Checklist +- [ ] Script runs without syntax errors +- [ ] All user inputs are validated +- [ ] Error messages are clear and helpful +- [ ] Script handles missing dependencies gracefully +- [ ] Interactive prompts work as expected +- [ ] Selection logic (ranges, individual items, "all") works correctly + +## 📝 Pull Request Guidelines + +### Before Submitting +- [ ] Your code follows the project's coding standards +- [ ] You have tested your changes thoroughly +- [ ] You have updated documentation if necessary +- [ ] Your commit messages are clear and descriptive + +### Pull Request Template +When creating a pull request, please include: + +1. **Description**: What does this PR do? +2. **Type of Change**: Bug fix, new feature, documentation update, etc. +3. **Testing**: How did you test your changes? +4. **Screenshots**: If applicable, add screenshots showing the script in action +5. **Related Issues**: Link any related issues + +### Example PR Description +```markdown +## Description +Adds a new script for bulk repository tagging with interactive selection. + +## Type of Change +- [x] New feature +- [ ] Bug fix +- [ ] Documentation update + +## Testing +- Tested with 50+ repositories +- Verified input validation with invalid selections +- Tested on macOS and Ubuntu + +## Screenshots +[Include screenshots of the script running] +``` + +## 🐛 Reporting Issues + +### Bug Reports +When reporting bugs, please include: +- Script name and version +- Operating system and shell version +- Steps to reproduce the issue +- Expected vs actual behavior +- Error messages (if any) + +### Feature Requests +For new features: +- Describe the use case +- Explain why this would be valuable +- Provide examples of how it would work + +## 🔍 Code Review Process + +1. **Automated Checks**: PRs will be automatically checked for basic requirements +2. **Maintainer Review**: A project maintainer will review your code +3. **Testing**: Changes will be tested in different environments +4. **Feedback**: You may receive feedback and requests for changes +5. **Merge**: Once approved, your PR will be merged + +## 📞 Getting Help + +- **Questions**: Open an issue with the "question" label +- **Discussions**: Use GitHub Discussions for general conversations +- **Direct Contact**: For sensitive issues, contact the maintainer directly + +## 📜 Code of Conduct + +This project follows a simple code of conduct: +- Be respectful and inclusive +- Focus on constructive feedback +- Help others learn and improve +- Maintain a professional environment + +## 🏆 Recognition + +Contributors will be recognized in: +- The project's README file +- Release notes for significant contributions +- GitHub's contributor graph + +Thank you for contributing to the GitHub Scripts Collection! 🎉 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5451756 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 NoroSaroyan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 185c94b..55c242a 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,15 @@ This repository contains additional scripts for various GitHub management tasks: This is an evolving collection of GitHub automation tools. Contributions, suggestions, and improvements are welcome! +**Please read our [Contributing Guidelines](CONTRIBUTING.md) before submitting any changes.** + +### Quick Start for Contributors +1. Fork the repository +2. Create a feature branch +3. Make your changes following our coding standards +4. Test thoroughly on different platforms +5. Submit a pull request with detailed description + ### Adding New Scripts When contributing new scripts, please ensure they: - Follow the existing code style and structure diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..2c15870 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,96 @@ +# Security Policy + +## Supported Versions + +We actively maintain and provide security updates for the following versions: + +| Version | Supported | +| ------- | ------------------ | +| Latest | :white_check_mark: | +| < Latest| :x: | + +## Reporting a Vulnerability + +We take the security of our scripts seriously. If you discover a security vulnerability, please follow these steps: + +### 1. **Do Not** Create a Public Issue +Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests. + +### 2. **Send a Private Report** +Create a private security advisory on GitHub. + +Include the following information: +- Type of issue (e.g., code injection, privilege escalation, etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit it + +### 3. **What to Expect** +- **Acknowledgment**: We will acknowledge receipt of your vulnerability report within 48 hours +- **Assessment**: We will assess the vulnerability and its impact within 5 business days +- **Updates**: We will provide regular updates on our progress +- **Resolution**: We aim to resolve critical vulnerabilities within 30 days + +### 4. **Disclosure Timeline** +- We will work with you to coordinate disclosure +- We prefer responsible disclosure after a fix is available +- We will credit you in the security advisory (unless you prefer to remain anonymous) + +## Security Best Practices for Users + +### Script Execution +- **Review scripts** before running them on your system +- **Run with minimal privileges** - don't use sudo unless absolutely necessary +- **Test in non-production environments** first +- **Keep dependencies updated** (GitHub CLI, jq, etc.) + +### GitHub Authentication +- **Use fine-grained personal access tokens** when possible +- **Regularly rotate** your GitHub credentials +- **Review token permissions** periodically +- **Don't share credentials** or commit them to repositories + +### Repository Management +- **Backup important repositories** before running bulk operations +- **Test on a few repositories** before processing large batches +- **Review script outputs** for any unexpected behavior +- **Use dry-run modes** when available + +## Common Security Considerations + +### Input Validation +Our scripts include input validation, but always: +- **Verify repository names** before processing +- **Check selection ranges** to avoid unintended operations +- **Validate user permissions** for target repositories + +### API Rate Limiting +- Scripts respect GitHub API rate limits +- **Monitor your API usage** in the GitHub settings +- **Use authenticated requests** for higher rate limits + +### Error Handling +- Scripts include error handling for common scenarios +- **Check exit codes** and error messages +- **Report unexpected behaviors** through proper channels + +## Security Updates + +We will announce security updates through: +- **GitHub Security Advisories** +- **Release notes** with clear security indicators +- **README updates** for critical security information + +## Contact + +For any security-related questions or concerns: +- **Email**: noro.saroyan@gmail.com +- **GitHub Security Advisories**: Available in this repository +- **Encrypted communication**: Available upon request + +--- + +Thank you for helping keep our project and community safe! diff --git a/mass-publicize-repos.sh b/mass-publicize-repos.sh old mode 100644 new mode 100755