-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
35 lines (28 loc) · 911 Bytes
/
index.js
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
28
29
30
31
32
33
34
import * as core from '@actions/core';
import { getHeadlines } from './utils/getHeadlines.js';
import { lockIssue, openIssue } from './utils/issue.js';
import { updateFeed } from './utils/feed.js';
const date = new Date();
const takeHeadlines = 30;
const contents = await getHeadlines(date, takeHeadlines);
if (!contents) {
core.warning("no content - skip issue creation");
process.exit(1);
}
core.info(contents);
if (process.env.BRANCH_NAME === 'main') {
const res = await openIssue({
owner: 'meixger',
repo: 'hackernews-daily',
title: `Hacker News Daily Top ${takeHeadlines} @${date.toISOString().slice(0, 10)}`,
body: contents
});
const issueNumber = res.data.number;
core.info(`created issue ${issueNumber}`);
await lockIssue({
owner: 'meixger',
repo: 'hackernews-daily',
issueNumber,
});
}
await updateFeed();