-
Notifications
You must be signed in to change notification settings - Fork 410
feat: Add new process and move contributors #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
dd82a90
6d02b42
e03b565
114bb97
fb35348
2b2632c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,48 +1,59 @@ | ||||||||||||||||||||||||
| <!-- Please fill in all areas in this PR form. Incomplete PRs will be marked invalid and may be closed. --> | ||||||||||||||||||||||||
| ## Type of Contribution | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Description | ||||||||||||||||||||||||
| <!-- Please check ONE box that best describes your contribution --> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| <!-- | ||||||||||||||||||||||||
| Please do not leave this blank. Add your description **below** this line and **outside** of the comment tags. | ||||||||||||||||||||||||
| For example: This PR adds <your-github-username> as a contributor. | ||||||||||||||||||||||||
| --> | ||||||||||||||||||||||||
| - [ ] 🎉 **Adding myself as a new contributor** (following the intro course) | ||||||||||||||||||||||||
| - [ ] 🐛 **Bug fix** | ||||||||||||||||||||||||
| - [ ] ✨ **New feature** | ||||||||||||||||||||||||
| - [ ] 📝 **Documentation update** | ||||||||||||||||||||||||
| - [ ] 🔧 **Other maintenance/improvement** | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## What type of PR is this? (check all applicable) | ||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - [ ] 🤝 Add a contributor | ||||||||||||||||||||||||
| - [ ] 📝 Documentation Update | ||||||||||||||||||||||||
| ## For New Contributors (Adding Yourself to Guestbook) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Related Issues | ||||||||||||||||||||||||
| <!-- Only fill this section if you checked "Adding myself as a new contributor" above --> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| <!-- | ||||||||||||||||||||||||
| Add your related issue **below** this line and **outside** of the comment tags. | ||||||||||||||||||||||||
| ### Checklist for Adding Yourself | ||||||||||||||||||||||||
| - [ ] I created a file named `contributors/[my-github-username].json` | ||||||||||||||||||||||||
| - [ ] I filled in all required fields: `name`, `github`, `contributions`, `profile` | ||||||||||||||||||||||||
| - [ ] I only added ONE file (my contributor JSON file) | ||||||||||||||||||||||||
| - [ ] My JSON file is valid (no syntax errors) | ||||||||||||||||||||||||
| - [ ] I'm completing the [Intro to Open Source course](https://opensauced.pizza/learn/intro-to-oss/) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Please use this format to link your issue: Closes #XXX. | ||||||||||||||||||||||||
| Change "XXX" to your issue number that you can find next to your issue's title. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| More information about link issue: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue | ||||||||||||||||||||||||
| --> | ||||||||||||||||||||||||
| ### About Me | ||||||||||||||||||||||||
| **Name:** | ||||||||||||||||||||||||
| **Location (optional):** | ||||||||||||||||||||||||
| **What I'm learning:** | ||||||||||||||||||||||||
| **Fun fact:** | ||||||||||||||||||||||||
|
Comment on lines
+24
to
+28
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Do we need this section in the PR? Would it be better if we can suggest for folks to introduce themselves at GH discussion? fix: If we want to keep this, we need some fix. The Markdown preview for this format is off because everything is inline. Let's change this to list instead.
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Contributors Checklist | ||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### I've read through the [Getting Started](https://intro.opensauced.pizza/#/intro-to-oss/how-to-contribute-to-open-source?id=getting-started) section | ||||||||||||||||||||||||
| ## For Other Contributions | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - [ ] ✅ Yes | ||||||||||||||||||||||||
| - [ ] ❌ Not yet | ||||||||||||||||||||||||
| <!-- Fill this section for bug fixes, features, documentation, etc. --> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Have you run `npm run contributors:generate` to generate your profile and the badge on the README? | ||||||||||||||||||||||||
| ### Description | ||||||||||||||||||||||||
| <!-- Describe what this PR changes and why --> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - [ ] ✅ Yes | ||||||||||||||||||||||||
| - [ ] ❌ No | ||||||||||||||||||||||||
| ### Changes Made | ||||||||||||||||||||||||
| <!-- List the specific changes --> | ||||||||||||||||||||||||
| - | ||||||||||||||||||||||||
| - | ||||||||||||||||||||||||
| - | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Added to documentation? | ||||||||||||||||||||||||
| ### Screenshots (if applicable) | ||||||||||||||||||||||||
| <!-- Add screenshots for UI changes --> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - [ ] 📜 README.md | ||||||||||||||||||||||||
| - [ ] 🙅 no documentation needed | ||||||||||||||||||||||||
| ### Testing | ||||||||||||||||||||||||
| - [ ] I have tested these changes locally | ||||||||||||||||||||||||
| - [ ] I have reviewed my own code | ||||||||||||||||||||||||
| - [ ] I have added/updated documentation if needed | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Screenshot (Required for PR Review) | ||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| <!-- Please provide a screenshot of your profile being generated on the README. This ensures that you ran the `npm run contributors:generate` command, as mentioned in the previous question, which makes it easier for the maintainers to review PRs. All PRs without screenshots will be automatically rejected--> | ||||||||||||||||||||||||
| ## Additional Notes | ||||||||||||||||||||||||
| <!-- Any additional context, concerns, or information --> | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## [optional] What GIF best describes this PR or how it makes you feel? | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| name: Update Contributors | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: ['contributors/*.json'] | ||
|
|
||
| # Allow manual triggering for maintenance | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| update-contributors: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| npm install -g all-contributors-cli | ||
|
|
||
| - name: Backup current contributors | ||
| run: | | ||
| cp .all-contributorsrc .all-contributorsrc.backup || echo "No existing config found" | ||
|
|
||
| - name: Reset all-contributors config | ||
| run: | | ||
| # Create fresh config | ||
| cat > .all-contributorsrc << 'EOF' | ||
| { | ||
| "projectName": "guestbook", | ||
| "projectOwner": "OpenSource-Community", | ||
| "repoType": "github", | ||
| "repoHost": "https://github.com", | ||
| "files": ["README.md"], | ||
| "imageSize": 100, | ||
| "commit": false, | ||
| "commitConvention": "angular", | ||
| "contributors": [] | ||
| } | ||
| EOF | ||
|
|
||
| - name: Process contributor files | ||
| run: | | ||
| echo "Processing contributor files..." | ||
|
|
||
| # Check if contributors directory exists and has files | ||
| if [ ! -d "contributors" ] || [ -z "$(ls -A contributors/*.json 2>/dev/null)" ]; then | ||
| echo "No contributor files found" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Count total files to process | ||
| total_files=$(ls -1 contributors/*.json 2>/dev/null | grep -v -E '(example-contributor\.json|\.gitkeep|README\.md)' | wc -l) | ||
| echo "Found $total_files contributor files to process" | ||
|
|
||
| # Process each JSON file | ||
| processed=0 | ||
| for file in contributors/*.json; do | ||
| if [ -f "$file" ]; then | ||
| filename=$(basename "$file") | ||
|
|
||
| # Skip example and template files | ||
| if [[ "$filename" == "example-contributor.json" ]] || [[ "$filename" == ".gitkeep" ]] || [[ "$filename" == "README.md" ]]; then | ||
| echo "Skipping template file: $filename" | ||
| continue | ||
| fi | ||
|
|
||
| echo "Processing $file" | ||
|
|
||
| # Validate JSON (basic check) | ||
| if ! python3 -c "import json; json.load(open('$file'))" 2>/dev/null; then | ||
| echo "Error: Invalid JSON in $file" | ||
| continue | ||
| fi | ||
|
|
||
| # Extract data using Python since jq might not be available | ||
| username=$(basename "$file" .json) | ||
| name=$(python3 -c "import json; data=json.load(open('$file')); print(data.get('name', ''))") | ||
| github_username=$(python3 -c "import json; data=json.load(open('$file')); print(data.get('github', ''))") | ||
| profile=$(python3 -c "import json; data=json.load(open('$file')); print(data.get('profile', ''))") | ||
| contributions=$(python3 -c "import json; data=json.load(open('$file')); print(','.join(data.get('contributions', [])))") | ||
|
|
||
| # Validate required fields | ||
| if [ -z "$name" ] || [ -z "$github_username" ] || [ -z "$contributions" ]; then | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Is |
||
| echo "Error: Missing required fields in $file" | ||
| continue | ||
| fi | ||
|
|
||
| # Add contributor | ||
| echo "Adding contributor: $name (@$github_username)" | ||
|
|
||
| if [ -n "$profile" ] && [ "$profile" != "null" ] && [ "$profile" != "" ]; then | ||
| npx all-contributors add "$github_username" "$contributions" --url "$profile" --name "$name" | ||
| else | ||
| npx all-contributors add "$github_username" "$contributions" --name "$name" | ||
| fi | ||
|
|
||
| processed=$((processed + 1)) | ||
| fi | ||
| done | ||
|
|
||
| echo "✅ Processed $processed contributor files" | ||
|
|
||
| - name: Generate contributors section | ||
| run: | | ||
| npx all-contributors generate | ||
|
|
||
| - name: Check for changes | ||
| id: changes | ||
| run: | | ||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changes=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Commit and push changes | ||
| if: steps.changes.outputs.changes == 'true' | ||
| run: | | ||
| git config --local user.email "[email protected]" | ||
| git config --local user.name "Contributors Bot" | ||
|
|
||
| git add . | ||
| git commit -m "chore: update contributors list | ||
|
|
||
| Auto-generated from contributors/*.json files | ||
|
|
||
| [skip ci]" | ||
| git push | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Success notification | ||
| if: steps.changes.outputs.changes == 'true' | ||
| run: | | ||
| echo "✅ Contributors list updated successfully!" | ||
| echo "Changes committed and pushed to main branch." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: Validate Contributor | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'contributors/*.json' | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout PR | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '18' | ||
|
|
||
| - name: Get changed files | ||
| id: changed-files | ||
| uses: tj-actions/changed-files@v39 | ||
| with: | ||
| files: | | ||
| contributors/*.json | ||
|
|
||
| - name: Validate contributor files | ||
| if: steps.changed-files.outputs.any_changed == 'true' | ||
| run: | | ||
| echo "🔍 Validating contributor files..." | ||
|
|
||
| # Install dependencies | ||
| npm install | ||
|
|
||
| # Run validation | ||
| node scripts/validate-contributor.js | ||
|
|
||
| # Check specific changed files | ||
| for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
| echo "Checking $file" | ||
|
|
||
| if [[ "$file" == contributors/*.json ]]; then | ||
| filename=$(basename "$file") | ||
| username="${filename%.json}" | ||
|
|
||
| # Run preview for the specific file | ||
| echo "Preview for $username:" | ||
| node scripts/preview-contribution.js "$username" | ||
| fi | ||
| done | ||
|
|
||
| - name: Comment on PR | ||
| if: failure() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: '❌ Your contributor file has validation errors. Please check the [action logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.\n\nCommon issues:\n- Username in filename must match the `github` field in JSON\n- All required fields must be present: `name`, `github`, `contributions`\n- Use valid contribution types\n\nNeed help? Check the [contributor guide](docs/guides/contributor-guide.md).' | ||
| }) | ||
|
|
||
| - name: Success comment | ||
| if: success() && steps.changed-files.outputs.any_changed == 'true' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: '✅ Your contributor file is valid! Once this PR is merged, you\'ll automatically appear in the contributors section.\n\nThank you for your contribution! 🎉' | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Validate Contributors | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'contributors/*.json' | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'contributors/*.json' | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.x' | ||
|
|
||
| - name: Validate contributor files | ||
| run: | | ||
| python3 scripts/validate-contributor.py | ||
|
|
||
| - name: Check for duplicate contributors | ||
| run: | | ||
| # Check for duplicate GitHub usernames | ||
| duplicates=$(find contributors/ -name "*.json" -exec basename {} .json \; | sort | uniq -d) | ||
| if [ -n "$duplicates" ]; then | ||
| echo "❌ Duplicate contributor files found:" | ||
| echo "$duplicates" | ||
| exit 1 | ||
| else | ||
| echo "✅ No duplicate contributors found" | ||
| fi | ||
|
|
||
| - name: Validate JSON syntax | ||
| run: | | ||
| echo "🔍 Validating JSON syntax..." | ||
| for file in contributors/*.json; do | ||
| if [ -f "$file" ]; then | ||
| echo "Checking $file..." | ||
| python3 -c "import json; json.load(open('$file'))" || { | ||
| echo "❌ Invalid JSON in $file" | ||
| exit 1 | ||
| } | ||
| fi | ||
| done | ||
| echo "✅ All JSON files have valid syntax" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts: I feel like creating an issue and link it to the PR is one good ways to teach contributors about the importance of opening an issue when they want to add feature or fix bugs. It's also considered as one of OSS best practices, although some repos don't require this anymore for small fixes.
suggestions: Keep creating an issue as part of contributing to guestbook repo. Therefore, keep this section here, also at the course.