summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-05-05 00:08:14 +0300
committerAndreas Kling <kling@serenityos.org>2021-05-05 21:12:09 +0200
commitb9c367e13b0e8eeec9cb085876b3306c24a9f2fd (patch)
treee3e64a7ada40a39d5a06f83352958a74977b04ac /Meta
parent2156c728cdd8e5a223d986869275a696ee2ef128 (diff)
downloadserenity-b9c367e13b0e8eeec9cb085876b3306c24a9f2fd.zip
Meta: Add action to tweet each commit on push
Diffstat (limited to 'Meta')
-rw-r--r--Meta/tweet-commits.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/Meta/tweet-commits.js b/Meta/tweet-commits.js
new file mode 100644
index 0000000000..581eafe394
--- /dev/null
+++ b/Meta/tweet-commits.js
@@ -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);
+ }
+ }
+})();