-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
27 lines (21 loc) · 978 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as github from '@actions/github';
import { getInput } from '@actions/core';
const slug = process.env.GITHUB_REPOSITORY!
const [owner, repo] = slug.split('/')
const issue_number = parseInt((getInput('yesterday') || process.env.GTD_YESTERDAY)!)
const today = parseInt((getInput('today') || process.env.GTD_TODAY)!)
const token = getInput('token')!
const octokit = github.getOctokit(token)
const comments = await octokit.rest.issues.listComments({ owner, repo, issue_number })
for (const comment of comments.data) {
const reactions = await octokit.rest.reactions.listForIssueComment({
owner, repo, comment_id: comment.id
})
if (!reactions.data.map(rxn => rxn.content).includes('eyes')) continue;
const new_comment = await octokit.rest.issues.createComment({
owner, repo, issue_number: today, body: comment.body ?? ''
})
await octokit.rest.reactions.createForIssueComment({
owner, repo, comment_id: new_comment.data.id, content: 'eyes'
})
}