-
Notifications
You must be signed in to change notification settings - Fork 438
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
Draft
BekahHW
wants to merge
17
commits into
main
Choose a base branch
from
feat/contributor-pr-help
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
dd82a90
Add new process and move contributors
BekahHW 6d02b42
Update .github/PULL_REQUEST_TEMPLATE.md
BekahHW e03b565
Update .github/workflows/validate-pr.yml
BekahHW 114bb97
Add node.js testing and address some comments
BekahHW fb35348
Add node.js testing and address some comments
BekahHW 2b2632c
Fix merge errors
BekahHW 553044d
Change discussion link in CONTRIBUTING.mdfix: update discussion link …
BekahHW ffc3517
Update contribution sharing link in workflowfix: replace OpenSauced D…
BekahHW 6f69f05
fix: remove defunct OpenSauced links and update community reference i…
BekahHW 9cab83a
fix: remove defunct OpenSauced links from testing guide next steps
BekahHW 908fd37
Update pull request template for clarityfix: convert About Me fields …
BekahHW 7fb983d
fix: replace invalid all-contributors CLI flags with direct .all-cont…
BekahHW b5fcb59
Merge branch 'main' into feat/contributor-pr-help
BekahHW be11782
fix: replace Python3 with Node.js in update-contributors workflow
BekahHW 25bd61a
fix: correct YAML indentation in update-contributors workflow
BekahHW 0dcc306
fix: correct Python to Node.js translation with proper YAML indentation
BekahHW 0feeca6
Merge branch 'main' into feat/contributor-pr-help
BekahHW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| 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: | | ||
| node -e "const fs=require('fs'); fs.writeFileSync('.all-contributorsrc', JSON.stringify({projectName:'guestbook',projectOwner:'OpenSource-Community',repoType:'github',repoHost:'https://github.com',files:['README.md'],imageSize:100,commit:false,commitConvention:'angular',contributors:[]},null,2));" | ||
|
|
||
| - name: Write contributor update script | ||
| run: | | ||
| cat > /tmp/add-contributor.js << 'EOF' | ||
| const fs = require('fs'); | ||
| const filePath = process.argv[2]; | ||
| const rcFile = '.all-contributorsrc'; | ||
| const d = JSON.parse(fs.readFileSync(filePath, 'utf8')); | ||
| const rc = JSON.parse(fs.readFileSync(rcFile, 'utf8')); | ||
| const username = d.github || ''; | ||
| const existing = rc.contributors.find(c => c.login === username); | ||
| if (!existing && username) { | ||
| rc.contributors.push({ | ||
| login: username, | ||
| name: d.name || '', | ||
| avatar_url: 'https://avatars.githubusercontent.com/' + username, | ||
| profile: d.profile || ('https://github.com/' + username), | ||
| contributions: d.contributions || [] | ||
| }); | ||
| fs.writeFileSync(rcFile, JSON.stringify(rc, null, 2)); | ||
| console.log('Added: ' + username); | ||
| } else if (existing) { | ||
| console.log('Already exists: ' + username); | ||
| } else { | ||
| console.error('Error: missing github field in ' + filePath); | ||
| process.exit(1); | ||
| } | ||
| EOF | ||
|
|
||
| - name: Process contributor files | ||
| run: | | ||
| echo "Processing contributor files..." | ||
|
|
||
| if [ ! -d "contributors" ] || [ -z "$(ls -A contributors/*.json 2>/dev/null)" ]; then | ||
| echo "No contributor files found" | ||
| exit 0 | ||
| fi | ||
|
|
||
| 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" | ||
|
|
||
| processed=0 | ||
| for file in contributors/*.json; do | ||
| if [ -f "$file" ]; then | ||
| filename=$(basename "$file") | ||
|
|
||
| if [[ "$filename" == "example-contributor.json" ]] || [[ "$filename" == ".gitkeep" ]] || [[ "$filename" == "README.md" ]]; then | ||
| echo "Skipping template file: $filename" | ||
| continue | ||
| fi | ||
|
|
||
| echo "Processing $file" | ||
|
|
||
| if ! node -e "JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'))" "$file" 2>/dev/null; then | ||
| echo "Error: Invalid JSON in $file" | ||
| continue | ||
| fi | ||
|
|
||
| name=$(node -e "const d=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8')); process.stdout.write(d.name||'')" "$file") | ||
| github_username=$(node -e "const d=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8')); process.stdout.write(d.github||'')" "$file") | ||
| contributions=$(node -e "const d=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8')); process.stdout.write((d.contributions||[]).join(','))" "$file") | ||
|
|
||
| if [ -z "$name" ] || [ -z "$github_username" ] || [ -z "$contributions" ]; then | ||
| echo "Error: Missing required fields in $file" | ||
| continue | ||
| fi | ||
|
|
||
| echo "Adding contributor: $name (@$github_username)" | ||
| node /tmp/add-contributor.js "$file" | ||
|
|
||
| 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 "action@github.com" | ||
| 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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! 🎉' | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.