Merge pull request #10 from mahmudul-Hasan-2/week-1-solution #13
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
| name: Welcome New Contributors | ||
| on: | ||
| pull_request: | ||
| types: [opened] | ||
| issues: | ||
| types: [opened] | ||
| workflow_dispatch: | ||
| jobs: | ||
| welcome: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Welcome Contributor | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const issue = context.payload.issue || context.payload.pull_request; | ||
| if (!issue) return; | ||
| const login = issue.user.login; | ||
| const repo = context.repo.repo; | ||
| // Only welcome first-time contributors | ||
| const result = await github.rest.search.issuesAndPullRequests({ | ||
| q: `repo:${context.repo.owner}/${repo} author:${login}` | ||
| }); | ||
| const isFirstTime = (result.data.total_count <= 1); | ||
| if (isFirstTime) { | ||
| const welcomeMessage = ` | ||
| Hi @${login}! π | ||
| Welcome to **ReactSphere Community Challenges**! π | ||
| Hereβs how to get started: | ||
| - Check out the weekly challenges in [challenges/](https://github.com/${context.repo.owner}/${repo}/tree/main/challenges) | ||
| - Submit your solutions via Pull Requests | ||
| - Track your progress on the [Leaderboard](https://github.com/${context.repo.owner}/${repo}/blob/main/LEADERBOARD.md) | ||
| - Join discussions or ask questions via Issues or Discussions | ||
| Happy contributing! π | ||
| `; | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo, | ||
| issue_number: issue.number, | ||
| body: welcomeMessage | ||
| }); | ||
| } | ||