mirror of
https://github.com/wshobson/agents.git
synced 2026-03-18 09:37:15 +00:00
Fix GitHub Actions welcome workflow using best practices
Problem Analysis: - Original workflow used complex GitHub search API causing rate limiting issues - Custom first-time contributor detection was unreliable and fragile - Used pull_request instead of pull_request_target for PRs (security issue) - Complex github-script logic prone to failures Solution Implemented: - Replaced custom logic with GitHub's official actions/first-interaction@v1 - Changed to pull_request_target for PR security and reliability - Eliminated API rate limiting issues by removing search calls - Simplified permissions and workflow structure - Added comprehensive welcome messages with community guidelines Benefits: - More reliable first-time contributor detection - No rate limiting issues - Better security with pull_request_target - Easier to maintain using official GitHub action - Consistent messaging across issues and PRs Also included alternative implementation example using garg3133/welcome-new-contributors@v1.2
This commit is contained in:
102
.github/workflows/welcome-new-contributors-alternative.yml.example
vendored
Normal file
102
.github/workflows/welcome-new-contributors-alternative.yml.example
vendored
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
# Alternative Welcome Workflow using third-party action
|
||||||
|
# This is an example implementation using garg3133/welcome-new-contributors
|
||||||
|
# Rename to .yml and adjust the main workflow if you prefer this approach
|
||||||
|
|
||||||
|
name: Welcome New Contributors (Alternative)
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
welcome:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Welcome first-time contributors
|
||||||
|
uses: garg3133/welcome-new-contributors@v1.2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-message: |
|
||||||
|
👋 **Welcome to the Claude Code Agents project, @contributor_name!**
|
||||||
|
|
||||||
|
Thank you for opening your first issue! We appreciate your interest in contributing to our collection of specialized subagents.
|
||||||
|
|
||||||
|
## 📋 Community Guidelines
|
||||||
|
|
||||||
|
Before we proceed, please take a moment to review our community standards:
|
||||||
|
|
||||||
|
- 📖 **[Code of Conduct](.github/CODE_OF_CONDUCT.md)** - Our community standards and behavioral expectations
|
||||||
|
- 🤝 **[Contributing Guidelines](.github/CONTRIBUTING.md)** - How to contribute effectively
|
||||||
|
- 💬 **[GitHub Discussions](https://github.com/wshobson/agents/discussions)** - For questions and general discussion
|
||||||
|
|
||||||
|
## 🛡️ Community Values
|
||||||
|
|
||||||
|
We maintain a **respectful, inclusive, and professional environment**. Our community does not tolerate:
|
||||||
|
- Hate speech, discrimination, or harassment
|
||||||
|
- Personal attacks or inflammatory language
|
||||||
|
- Spam, trolling, or off-topic content
|
||||||
|
- Any content that violates our Code of Conduct
|
||||||
|
|
||||||
|
## ✅ What Makes a Great Issue
|
||||||
|
|
||||||
|
- Clear, specific problem descriptions
|
||||||
|
- Steps to reproduce (for bugs)
|
||||||
|
- Constructive feature requests with use cases
|
||||||
|
- Professional, respectful language
|
||||||
|
|
||||||
|
## 🚀 Next Steps
|
||||||
|
|
||||||
|
A maintainer will review your issue soon. Please feel free to:
|
||||||
|
- Add any additional context if needed
|
||||||
|
- Respond to questions from maintainers
|
||||||
|
- Join our [Discussions](https://github.com/wshobson/agents/discussions)
|
||||||
|
|
||||||
|
Thank you for helping make this project better! 🎉
|
||||||
|
|
||||||
|
pr-message: |
|
||||||
|
👋 **Welcome to the Claude Code Agents project, @contributor_name!**
|
||||||
|
|
||||||
|
Thank you for opening your first pull request! We appreciate your interest in contributing to our collection of specialized subagents.
|
||||||
|
|
||||||
|
## 📋 Community Guidelines
|
||||||
|
|
||||||
|
Before we proceed, please take a moment to review our community standards:
|
||||||
|
|
||||||
|
- 📖 **[Code of Conduct](.github/CODE_OF_CONDUCT.md)** - Our community standards and behavioral expectations
|
||||||
|
- 🤝 **[Contributing Guidelines](.github/CONTRIBUTING.md)** - How to contribute effectively
|
||||||
|
- 💬 **[GitHub Discussions](https://github.com/wshobson/agents/discussions)** - For questions and general discussion
|
||||||
|
|
||||||
|
## 🛡️ Community Values
|
||||||
|
|
||||||
|
We maintain a **respectful, inclusive, and professional environment**. Our community does not tolerate:
|
||||||
|
- Hate speech, discrimination, or harassment
|
||||||
|
- Personal attacks or inflammatory language
|
||||||
|
- Spam, trolling, or off-topic content
|
||||||
|
- Any content that violates our Code of Conduct
|
||||||
|
|
||||||
|
## ✅ What Makes a Great Pull Request
|
||||||
|
|
||||||
|
- Well-documented changes with clear descriptions
|
||||||
|
- Following existing code style and conventions
|
||||||
|
- Clear, descriptive commit messages
|
||||||
|
- Addressing a specific issue or improvement
|
||||||
|
- Including tests or examples where appropriate
|
||||||
|
|
||||||
|
## 🚀 Next Steps
|
||||||
|
|
||||||
|
A maintainer will review your pull request soon. Please feel free to:
|
||||||
|
- Add any additional context about your changes
|
||||||
|
- Respond to feedback and questions from maintainers
|
||||||
|
- Join our [Discussions](https://github.com/wshobson/agents/discussions)
|
||||||
|
|
||||||
|
Thank you for helping make this project better! 🎉
|
||||||
|
|
||||||
|
# Optional: Add labels to first-time contributor issues/PRs
|
||||||
|
issue-labels: 'first-time-contributor, needs-review'
|
||||||
|
pr-labels: 'first-time-contributor, needs-review'
|
||||||
143
.github/workflows/welcome-new-contributors.yml
vendored
143
.github/workflows/welcome-new-contributors.yml
vendored
@@ -3,7 +3,7 @@ name: Welcome New Contributors
|
|||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened]
|
types: [opened]
|
||||||
pull_request:
|
pull_request_target:
|
||||||
types: [opened]
|
types: [opened]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -14,92 +14,83 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check if first-time contributor
|
|
||||||
id: check-contributor
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const author = context.payload.sender.login;
|
|
||||||
|
|
||||||
// Check if this is their first contribution
|
|
||||||
const { data: issues } = await github.rest.search.issuesAndPullRequests({
|
|
||||||
q: `repo:${context.repo.owner}/${context.repo.repo} author:${author}`,
|
|
||||||
sort: 'created',
|
|
||||||
order: 'asc',
|
|
||||||
per_page: 2
|
|
||||||
});
|
|
||||||
|
|
||||||
const isFirstTime = issues.items.length <= 1;
|
|
||||||
core.setOutput('is-first-time', isFirstTime);
|
|
||||||
core.setOutput('author', author);
|
|
||||||
|
|
||||||
console.log(`User ${author} is ${isFirstTime ? 'a first-time' : 'a returning'} contributor`);
|
|
||||||
|
|
||||||
- name: Welcome first-time contributors
|
- name: Welcome first-time contributors
|
||||||
if: steps.check-contributor.outputs.is-first-time == 'true'
|
uses: actions/first-interaction@v1
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
with:
|
||||||
script: |
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
const author = '${{ steps.check-contributor.outputs.author }}';
|
issue-message: |
|
||||||
const isIssue = context.eventName === 'issues';
|
👋 **Welcome to the Claude Code Agents project, @${{ github.actor }}!**
|
||||||
const number = isIssue ? context.payload.issue.number : context.payload.pull_request.number;
|
|
||||||
|
|
||||||
const welcomeMessage = `👋 **Welcome to the Claude Code Agents project, @${author}!**
|
|
||||||
|
|
||||||
Thank you for your ${isIssue ? 'issue submission' : 'pull request'}! We appreciate your interest in contributing to our collection of specialized subagents.
|
Thank you for opening your first issue! We appreciate your interest in contributing to our collection of specialized subagents.
|
||||||
|
|
||||||
## 📋 Community Guidelines
|
## 📋 Community Guidelines
|
||||||
|
|
||||||
Before we proceed, please take a moment to review our community standards:
|
Before we proceed, please take a moment to review our community standards:
|
||||||
|
|
||||||
- 📖 **[Code of Conduct](.github/CODE_OF_CONDUCT.md)** - Our community standards and behavioral expectations
|
- 📖 **[Code of Conduct](.github/CODE_OF_CONDUCT.md)** - Our community standards and behavioral expectations
|
||||||
- 🤝 **[Contributing Guidelines](.github/CONTRIBUTING.md)** - How to contribute effectively
|
- 🤝 **[Contributing Guidelines](.github/CONTRIBUTING.md)** - How to contribute effectively
|
||||||
- 💬 **[GitHub Discussions](https://github.com/${context.repo.owner}/${context.repo.repo}/discussions)** - For questions and general discussion
|
- 💬 **[GitHub Discussions](https://github.com/wshobson/agents/discussions)** - For questions and general discussion
|
||||||
|
|
||||||
## 🛡️ Community Values
|
## 🛡️ Community Values
|
||||||
|
|
||||||
We maintain a **respectful, inclusive, and professional environment**. Our community does not tolerate:
|
We maintain a **respectful, inclusive, and professional environment**. Our community does not tolerate:
|
||||||
- Hate speech, discrimination, or harassment
|
- Hate speech, discrimination, or harassment
|
||||||
- Personal attacks or inflammatory language
|
- Personal attacks or inflammatory language
|
||||||
- Spam, trolling, or off-topic content
|
- Spam, trolling, or off-topic content
|
||||||
- Any content that violates our Code of Conduct
|
- Any content that violates our Code of Conduct
|
||||||
|
|
||||||
## ✅ What Makes a Great Contribution
|
## ✅ What Makes a Great Issue
|
||||||
|
|
||||||
${isIssue ? `**For Issues:**
|
**For Issues:**
|
||||||
- Clear, specific problem descriptions
|
- Clear, specific problem descriptions
|
||||||
- Steps to reproduce (for bugs)
|
- Steps to reproduce (for bugs)
|
||||||
- Constructive feature requests with use cases
|
- Constructive feature requests with use cases
|
||||||
- Professional, respectful language` : `**For Pull Requests:**
|
- Professional, respectful language
|
||||||
- Well-documented changes
|
|
||||||
- Following existing code style
|
|
||||||
- Clear commit messages
|
|
||||||
- Addressing a specific issue or improvement`}
|
|
||||||
|
|
||||||
## 🚀 Next Steps
|
## 🚀 Next Steps
|
||||||
|
|
||||||
A maintainer will review your ${isIssue ? 'issue' : 'pull request'} soon. Please feel free to:
|
A maintainer will review your issue soon. Please feel free to:
|
||||||
- Add any additional context if needed
|
- Add any additional context if needed
|
||||||
- Respond to questions from maintainers
|
- Respond to questions from maintainers
|
||||||
- Join our [Discussions](https://github.com/${context.repo.owner}/${context.repo.repo}/discussions) for general questions
|
- Join our [Discussions](https://github.com/wshobson/agents/discussions) for general questions
|
||||||
|
|
||||||
Thank you for helping make this project better! 🎉`;
|
Thank you for helping make this project better! 🎉
|
||||||
|
|
||||||
if (isIssue) {
|
pr-message: |
|
||||||
await github.rest.issues.createComment({
|
👋 **Welcome to the Claude Code Agents project, @${{ github.actor }}!**
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
Thank you for opening your first pull request! We appreciate your interest in contributing to our collection of specialized subagents.
|
||||||
issue_number: number,
|
|
||||||
body: welcomeMessage
|
## 📋 Community Guidelines
|
||||||
});
|
|
||||||
} else {
|
Before we proceed, please take a moment to review our community standards:
|
||||||
await github.rest.pulls.createReview({
|
|
||||||
owner: context.repo.owner,
|
- 📖 **[Code of Conduct](.github/CODE_OF_CONDUCT.md)** - Our community standards and behavioral expectations
|
||||||
repo: context.repo.repo,
|
- 🤝 **[Contributing Guidelines](.github/CONTRIBUTING.md)** - How to contribute effectively
|
||||||
pull_number: number,
|
- 💬 **[GitHub Discussions](https://github.com/wshobson/agents/discussions)** - For questions and general discussion
|
||||||
body: welcomeMessage,
|
|
||||||
event: 'COMMENT'
|
## 🛡️ Community Values
|
||||||
});
|
|
||||||
}
|
We maintain a **respectful, inclusive, and professional environment**. Our community does not tolerate:
|
||||||
|
- Hate speech, discrimination, or harassment
|
||||||
console.log(`Welcomed first-time contributor @${author}`);
|
- Personal attacks or inflammatory language
|
||||||
|
- Spam, trolling, or off-topic content
|
||||||
|
- Any content that violates our Code of Conduct
|
||||||
|
|
||||||
|
## ✅ What Makes a Great Pull Request
|
||||||
|
|
||||||
|
**For Pull Requests:**
|
||||||
|
- Well-documented changes with clear descriptions
|
||||||
|
- Following existing code style and conventions
|
||||||
|
- Clear, descriptive commit messages
|
||||||
|
- Addressing a specific issue or improvement
|
||||||
|
- Including tests or examples where appropriate
|
||||||
|
|
||||||
|
## 🚀 Next Steps
|
||||||
|
|
||||||
|
A maintainer will review your pull request soon. Please feel free to:
|
||||||
|
- Add any additional context about your changes
|
||||||
|
- Respond to feedback and questions from maintainers
|
||||||
|
- Join our [Discussions](https://github.com/wshobson/agents/discussions) for general questions
|
||||||
|
|
||||||
|
Thank you for helping make this project better! 🎉
|
||||||
Reference in New Issue
Block a user