Skip to content

Discrete Poisson solver English suggestions #61

Discrete Poisson solver English suggestions

Discrete Poisson solver English suggestions #61

on:
pull_request_target:
types: [closed]
permissions:
pull-requests: write
jobs:
comment_on_merged_pull_request:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Environment Variables
env:
AUTHOR: ${{ github.event.pull_request.user.login }}
REPO: ${{ github.event.repository.name }}
OWNER: ${{ github.event.repository.owner.login }}
run: |
echo "AUTHOR=${AUTHOR}" >> $GITHUB_ENV
echo "REPO=${REPO}" >> $GITHUB_ENV
echo "OWNER=${OWNER}" >> $GITHUB_ENV
- name: Count Merged Pull Requests
id: count_merged_pull_requests
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const author = process.env.AUTHOR;
const repo = process.env.REPO;
const owner = process.env.OWNER;
const { data } = await github.rest.search.issuesAndPullRequests({
q: `repo:${owner}/${repo} type:pr state:closed author:${author}`
});
const prCount = data.items.filter(pr => pr.pull_request.merged_at).length;
core.exportVariable('PR_COUNT', prCount);
} catch (error) {
core.setFailed(`Error counting merged pull requests: ${error.message}`);
}
- name: Comment on the Merged Pull Request
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const prCount = parseInt(process.env.PR_COUNT);
const author = process.env.AUTHOR;
const mention = 'amir-naveh';
const prNumber = context.payload.pull_request.number;
const repo = process.env.REPO;
function getRandomEmoji() {
const emojis = ['๐ŸŽ‰', '๐Ÿš€', '๐Ÿ’ช', '๐ŸŒŸ', '๐Ÿ†', '๐ŸŽŠ', '๐Ÿ”ฅ', '๐Ÿ‘', '๐ŸŒˆ', '๐Ÿš‚'];
return emojis[Math.floor(Math.random() * emojis.length)];
}
function getMessage(count) {
const emoji = getRandomEmoji();
switch(count) {
case 1:
return `${emoji} **Fantastic work @${author}!** Your very first PR to ${repo} has been merged! ๐ŸŽ‰๐Ÿฅณ\n\n` +
`If you're feeling adventurous, why not dive into another issue and keep contributing? The Classiq community would love to see more from you! ๐Ÿš€\n\n` +
`Happy coding! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป`;
case 2:
return `${emoji} **Well done @${author}!** Two PRs merged already! ๐ŸŽ‰๐Ÿฅณ\n\n` +
`With your second PR, you're on a roll, and your contributions are already making a difference. ๐ŸŒŸ\n` +
`Looking forward to seeing even more contributions from you. Keep up the great work! ๐Ÿš€`;
case 3:
return `${emoji} **You're on fire, @${author}!** Three PRs merged and counting! ๐Ÿ”ฅ๐ŸŽ‰\n\n` +
`Your consistent contributions are truly impressive. You're becoming a valued member of our community! ๐Ÿ’–\n` +
`Have you considered taking on some more challenging issues? We'd love to see what you can do! ๐Ÿ’ช\n\n`;
case 5:
return `${emoji} **High five, @${author}!** You've hit the incredible milestone of 5 merged PRs! ๐Ÿ–๏ธโœจ\n\n` +
`Your dedication to ${repo} is outstanding. You're not just contributing code; you're shaping the future of quantum computing! ๐ŸŒ \n` +
`We'd love to hear your thoughts on the project. Any ideas for new features or improvements? ๐Ÿค”\n\n` +
`You're a superstar! ๐ŸŒŸ`;
case 10:
return `${emoji} **Double digits, @${author}!** 10 merged PRs is a massive achievement! ๐Ÿ†๐ŸŽŠ\n\n` +
`Your impact on ${repo} is undeniable. You've become a pillar of our community! ๐Ÿ›๏ธ\n` +
`You're a quantum hero! ๐Ÿฆธโ€โ™€๏ธ๐Ÿฆธโ€โ™‚๏ธ`;
default:
if (count > 10) {
return `${emoji} **Incredible, @${author}!** You've merged your ${count}th PR! ๐ŸŽฏ๐ŸŽŠ\n\n` +
`Your ongoing commitment to ${repo} is truly remarkable. You're a driving force in our community! ๐Ÿš€\n` +
`Your contributions are helping to shape the future of quantum computing! What exciting features or improvements do you envision next? ๐Ÿ”ฎ\n\n` +
`We are grateful for your dedication! ๐Ÿ’ซ`;
} else {
return `${emoji} **Great job, @${author}!** You've merged your ${count}th PR! ๐ŸŽŠ\n\n` +
`Your contributions to ${repo} are making a real difference. Keep up the fantastic work! ๐Ÿ’ช\n` +
`Remember, every PR counts and helps improve the project. What will you tackle next? ๐Ÿค”\n\n`;
}
}
}
const message = getMessage(prCount);
await github.rest.issues.createComment({
owner: process.env.OWNER,
repo: process.env.REPO,
issue_number: prNumber,
body: message
});
} catch (error) {
core.setFailed(`Error creating comment: ${error.message}`);
}