Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Aug 16, 2022
1 parent cc3acaa commit 3609d55
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 28 deletions.
25 changes: 25 additions & 0 deletions index.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import core from "@actions/core";
import { TwitterApi } from "twitter-api-v2";
import { uploadImage, getLatestReleaseText } from "./helpers";

const IMG_URL =
"https://github.com/AddToDoist/AddToDoist/blob/main/assets/social-preview.png?raw=true";
const RELEASE_URL =
"https://api.github.com/repos/AddToDoist/AddToDoist/releases/latest";

const userClient = new TwitterApi({
appKey: core.getInput("consumer-key"),
appSecret: core.getInput("consumer-secret"),
accessToken: core.getInput("access-token"),
accessSecret: core.getInput("access-token-secret"),
});

try {
const [imageId, releaseText] = await Promise.all([
uploadImage(IMG_URL),
getLatestReleaseText(RELEASE_URL),
]);
await userClient.v2.tweet(releaseText, { media: { media_ids: [imageId] } });
} catch (err) {
core.setFailed(err.message);
}
Loading

0 comments on commit 3609d55

Please sign in to comment.