1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +00:00

Meta: Add action to tweet each commit on push

This commit is contained in:
Idan Horowitz 2021-05-05 00:08:14 +03:00 committed by Andreas Kling
parent 2156c728cd
commit b9c367e13b
2 changed files with 53 additions and 0 deletions

29
Meta/tweet-commits.js Normal file
View file

@ -0,0 +1,29 @@
const fs = require("fs");
const Twit = require("twit");
const { CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET } = process.env;
const T = new Twit({
consumer_key: CONSUMER_KEY,
consumer_secret: CONSUMER_SECRET,
access_token: ACCESS_TOKEN,
access_token_secret: ACCESS_TOKEN_SECRET,
});
(async () => {
const githubEvent = JSON.parse(fs.readFileSync(0).toString());
const tweets = [];
for (const commit of githubEvent["commits"]) {
tweets.push(
`${commit["message"].substring(0, 240)}\nAuthor: ${commit["author"]["name"]}\n${
commit["url"]
}`
);
}
for (const tweet of tweets) {
try {
await T.post("statuses/update", { status: tweet });
} catch (e) {
console.error("Failed to post a tweet!", e.message);
}
}
})();