generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.ts
30 lines (26 loc) · 787 Bytes
/
main.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
28
29
30
import * as core from '@actions/core'
import * as path from 'path'
import {tweet} from './tweet'
import {uploadMedia} from './upload-media'
async function run(): Promise<void> {
try {
const mediaPaths = core.getInput('media_paths')
const mediaIds = await uploadMedia(
mediaPaths
.split('\n')
.filter(x => x !== '')
.map(mediaPath => path.join(process.cwd(), mediaPath))
)
core.debug(`Media IDs: ${mediaIds.join(', ')}`)
const inReplyToStatusId = core.getInput('in_reply_to_status_id')
const response = await tweet(
core.getInput('status'),
mediaIds,
inReplyToStatusId
)
core.setOutput('response', response)
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}
}
run()