feat(editor): wrap long lines #53
Workflow file for this run
This file contains 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: Greet, Celebrate, and Encourage | |
on: | |
issues: | |
types: | |
- opened | |
- assigned | |
pull_request: | |
types: | |
- opened | |
pull_request_target: | |
types: | |
- closed | |
jobs: | |
greet: | |
name: Greet, Celebrate, and Encourage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check User Contributions | |
id: check_contributions | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const user = context.payload.sender.login; | |
const [userIssues, userPulls] = await Promise.all([ | |
github.rest.issues.listForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
creator: user, | |
state: 'all' | |
}), | |
github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'all', | |
creator: user | |
}) | |
]); | |
const totalContributions = userIssues.data.length + userPulls.data.length; | |
console.log(`User: ${user}, Issues: ${userIssues.length}, PRs: ${userPulls.length}, Total: ${totalContributions}`); | |
core.setOutput('isFirstTime', totalContributions === 1); | |
core.setOutput('totalContributions', totalContributions); | |
- name: Post Personalized Greeting | |
if: ${{ github.event.action == 'opened' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const user = context.payload.sender.login; | |
const isIssue = !!context.payload.issue; | |
const isPR = !!context.payload.pull_request; | |
const isFirstTime = '${{ steps.check_contributions.outputs.isFirstTime }}' === 'true'; | |
const totalContributions = parseInt('${{ steps.check_contributions.outputs.totalContributions }}'); | |
let message = ''; | |
if (isFirstTime) { | |
message = `๐ Welcome aboard, @${user}! ๐ | |
We're excited to see your **first contribution** to **Notpad**! ๐ | |
Every great project starts with contributors like you. ๐ก | |
Take a moment to check out our [CONTRIBUTING.md](https://github.com/Muhammed-Rahif/Notpad/blob/main/CONTRIBUTING.md) for tips and guidelines. | |
Feel free to explore, experiment, and engage with the community. | |
Your journey in open source starts here โ happy coding! ๐ฅ๏ธ`; | |
} | |
if (isIssue) { | |
message += ` | |
๐ Hi @${user}! Thank you for taking the time to report an issue in **Notpad**. | |
Weโll dive into it shortly. ๐ต๏ธโโ๏ธ๐ง | |
While you're here, why not add a โญ to the repo? [Click here to star](https://github.com/Muhammed-Rahif/Notpad/stargazers). | |
Your support helps us grow this project and reach more awesome contributors like you! ๐`; | |
} | |
if (isPR) { | |
message += ` | |
๐ Woohoo, @${user}! Thanks for opening a pull request to **Notpad**. ๐ ๏ธโจ | |
Your efforts make this project better with every contribution. | |
๐ก Before we merge this, donโt forget to check our [CONTRIBUTING.md](https://github.com/Muhammed-Rahif/Notpad/blob/main/CONTRIBUTING.md) for a smoother process. | |
Together, weโre building something incredible โ keep up the amazing work! ๐ช | |
(Psst... have you starred the repo yet? โญ)`; | |
} | |
if (totalContributions === 5) { | |
message += ` | |
๐ High five, @${user}! โ Youโve just hit a major milestone โ **5 contributions** to **Notpad**! | |
Contributors like you make this project shine brighter every day. ๐ | |
Your dedication inspires us, and we canโt wait to see what you come up with next. | |
A big thank you from the entire **Notpad** team โ we deeply appreciate your support. ๐ | |
Letโs keep building and making open source awesome together! ๐`; | |
} | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue?.number || context.payload.pull_request?.number, | |
body: message | |
}); | |
- name: Assign User Guidance | |
if: ${{ github.event.action == 'assigned' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const assignee = context.payload.assignee.login; | |
const issueNumber = context.payload.issue.number; | |
// Fetch issues and pull requests created by the assignee | |
const [issues, pulls] = await Promise.all([ | |
github.paginate(github.rest.issues.listForRepo, { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'all', | |
}), | |
github.paginate(github.rest.pulls.list, { | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'all', | |
}), | |
]); | |
// Filter to count only issues and pull requests created by the assignee | |
const assigneeIssues = issues.filter(issue => issue.user.login === assignee); | |
const assigneePulls = pulls.filter(pr => pr.user.login === assignee); | |
const totalContributions = assigneeIssues.length + assigneePulls.length; | |
// Log total contributions for debugging | |
// Compose the message based on contribution count | |
let message = ''; | |
if (totalContributions < 3) { | |
message = `๐ ๏ธ **Heads up, @${assignee}!** | |
You've been assigned an issue in **Notpad** โ ready to make your mark? ๐ | |
Since you're relatively new here, we highly recommend checking out our [CONTRIBUTING.md](https://github.com/Muhammed-Rahif/Notpad/blob/main/CONTRIBUTING.md). | |
Itโs packed with helpful tips, guidelines, and best practices to ensure a smooth contribution experience. | |
Weโre excited to see what youโll bring to the table โ happy coding! ๐ปโจ`; | |
} else { | |
message = `๐ Hi @${assignee}! You've been assigned an issue in **Notpad**. | |
Your contributions so far have been awesome, and we can't wait to see what you'll do next! ๐ | |
Remember to check out our [CONTRIBUTING.md](https://github.com/Muhammed-Rahif/Notpad/blob/main/CONTRIBUTING.md) for any guidelines or tips. | |
Let's build something great together! ๐ก`; | |
} | |
// Post the comment | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
body: message | |
}); | |
- name: Assign User Guidance | |
if: ${{ github.event.action == 'assigned' && steps.check_contributions.outputs.totalContributions < 3 }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const assignee = context.payload.assignee.login; | |
const issueNumber = context.payload.issue.number; | |
const message = `๐ ๏ธ **Heads up, @${assignee}!** | |
You've been assigned an issue in **Notpad** โ ready to make your mark? ๐ | |
Since you're relatively new here, we highly recommend checking out our [CONTRIBUTING.md](https://github.com/Muhammed-Rahif/Notpad/blob/main/CONTRIBUTING.md). | |
Itโs packed with helpful tips, guidelines, and best practices to ensure a smooth contribution experience. | |
Weโre excited to see what youโll bring to the table โ happy coding! ๐ปโจ`; | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
body: message | |
}); | |
- name: Thank Contributor When PR is Merged | |
if: ${{ github.event.action == 'closed' && github.event.pull_request.merged == true }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const pr = context.payload.pull_request; | |
const message = `๐ Congratulations, @${pr.user.login}! Your pull request has been successfully merged. ๐ฅณ๐ | |
Youโve just made **Notpad** better, and we couldnโt be more thankful. ๐ | |
Your contribution is now part of the project, helping users and contributors around the world. ๐ | |
Weโre excited to see what else you have in store for us โ the best is yet to come! ๐ก | |
Cheers to you and the amazing world of open source! ๐ปโจ`; | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pr.number, | |
body: message | |
}); |