Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
69 changes: 40 additions & 29 deletions .github/PULL_REQUEST_TEMPLATE.md
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
Copy link
Collaborator

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.

<!-- 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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
### About Me
**Name:**
**Location (optional):**
**What I'm learning:**
**Fun fact:**
### About Me
- **Name:**
- **Location (optional):**
- **What I'm learning:**
- **Fun fact:**


## 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?

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/intro_course_contributor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ jobs:
- name: Post comment for course contributors
if: contains(github.event.pull_request.title, 'as a contributor')
run: |
PR_COMMENT="Congratulations on completing the How to Contribute to Open Source chapter of the Intro to Open Source Course with your contribution to this repository, @${{ github.actor }}! You're almost to the end of the course. Create a [highlight](https://app.opensauced.pizza/feed) of your contribution to our guestbook using the instructions in the [next chapter](https://github.com/open-sauced/intro/blob/main/docs/intro-to-oss/the-secret-sauce.md) and share it with us!"
PR_COMMENT="Congratulations on completing the How to Contribute to Open Source chapter of the Intro to Open Source Course with your contribution to this repository, @${{ github.actor }}! You're almost to the end of the course."
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X POST -d "{\"body\":\"$PR_COMMENT\"}" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
150 changes: 150 additions & 0 deletions .github/workflows/update-contributors.yml
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is profile (link to website) required? If so, we need to add it here for validation.

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."
74 changes: 74 additions & 0 deletions .github/workflows/validate-contributor.yml
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! 🎉'
})
52 changes: 52 additions & 0 deletions .github/workflows/validate-contributors.yml
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"
Loading
Loading