-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
39 lines (32 loc) · 906 Bytes
/
index.mjs
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
35
36
37
38
39
import { getInput, setOutput, setFailed } from "@actions/core";
import { context } from "@actions/github";
import { AtpAgent } from "@atproto/api";
import { detectFacets } from "./utils.mjs";
async function runAction() {
console.log(`Triggered action: ${context.action}`);
const text = getInput("status");
const identifier = getInput("bluesky-email");
const password = getInput("bluesky-password");
const authority = getInput("authority") || 'bsky.social';
const agent = new AtpAgent({
service: `https://${authority}`,
});
await agent.login({
identifier,
password,
});
try {
const facets = detectFacets(text);
const result = await agent.post({
text,
facets,
});
setOutput("cid", result.cid);
setOutput("uri", result.uri);
return process.exit(0);
} catch (err) {
setFailed(err);
return process.exit(1);
}
}
runAction();