Skip to content

Commit 9ea8fae

Browse files
committed
first try of action
1 parent 4705d7b commit 9ea8fae

File tree

5 files changed

+28
-54
lines changed

5 files changed

+28
-54
lines changed

CODEOWNERS

Lines changed: 0 additions & 4 deletions
This file was deleted.

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
]
6767
},
6868
"dependencies": {
69-
"@actions/core": "^1.10.1"
69+
"@actions/core": "^1.10.1",
70+
"@actions/github": "^6.0.0"
7071
},
7172
"devDependencies": {
7273
"@types/jest": "^29.5.11",

src/main.ts

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
import * as core from '@actions/core'
2-
import { wait } from './wait'
2+
import * as github from '@actions/github'
3+
34

4-
/**
5-
* The main function for the action.
6-
* @returns {Promise<void>} Resolves when the action is complete.
7-
*/
85
export async function run(): Promise<void> {
96
try {
10-
const ms: string = core.getInput('milliseconds')
7+
const mainBranch: string = core.getInput('mainBranch') ?? 'dev'
8+
const token: string = core.getInput('token')
9+
10+
const octokit = github.getOctokit(token)
11+
const latestRelease = await octokit.rest.repos.getLatestRelease({ ...github.context.repo, })
1112

12-
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
13-
core.debug(`Waiting ${ms} milliseconds ...`)
13+
const pullRequests = await octokit.rest.pulls.list({
14+
...github.context.repo,
15+
base: latestRelease.data.target_commitish,
16+
head: mainBranch,
17+
state: 'closed',
18+
});
19+
const linearTickets = await Promise.all(pullRequests.data.map(async pr => {
20+
const comments = await octokit.rest.issues.listComments({
21+
...github.context.repo,
22+
issue_number: pr.number,
23+
});
24+
const linearComment = comments.data.find(c => {
25+
core.debug(`Comment by ${c.performed_via_github_app}`)
26+
return c.performed_via_github_app?.name === 'linear'
27+
})
28+
const ticket = linearComment?.body?.match(/\bRAY-\d+\b/)
29+
return ticket?.[0].match
30+
}).filter(Boolean))
1431

15-
// Log the current timestamp, wait, then log the new timestamp
16-
core.debug(new Date().toTimeString())
17-
await wait(parseInt(ms, 10))
18-
core.debug(new Date().toTimeString())
32+
core.debug(`Tickets found ${linearTickets.join()}`)
1933

20-
// Set outputs for other workflow steps to use
21-
core.setOutput('time', new Date().toTimeString())
2234
} catch (error) {
2335
// Fail the workflow run if an error occurs
2436
if (error instanceof Error) core.setFailed(error.message)

src/wait.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)