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: Add Emoji Reaction To Comments | |
on: | |
issue_comment: | |
types: [created, edited] | |
jobs: | |
add_emoji: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Add heart reaction to comment | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
if (context.payload.comment.user.login !== 'Hannes-Leitl-Senacor') { | |
console.log('The comment is not by Hannes, skipping...'); | |
await github.rest.reactions.createForIssueComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: context.payload.comment.id, | |
content: '+1', | |
}); | |
} else { | |
try { | |
await github.rest.reactions.createForIssueComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: context.payload.comment.id, | |
content: 'heart', | |
}); | |
console.log('Heart reaction added to the comment.'); | |
} catch (error) { | |
console.error('Failed to add reaction', error); | |
} | |
} |