mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Meta: Add action to tweet each commit on push
This commit is contained in:
parent
2156c728cd
commit
b9c367e13b
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/b9c367e13b0 Pull-request: https://github.com/SerenityOS/serenity/pull/6866 Reviewed-by: https://github.com/bgianfo ✅
2 changed files with 53 additions and 0 deletions
24
.github/workflows/twitter.yml
vendored
Normal file
24
.github/workflows/twitter.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
name: Twitter notifications
|
||||
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
notify_twitter:
|
||||
runs-on: ubuntu-20.04
|
||||
if: always() && github.repository == 'SerenityOS/serenity' && github.ref == 'refs/heads/master'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node_version: '14'
|
||||
- run: npm i twit
|
||||
- run: |
|
||||
node ${{ github.workspace }}/Meta/tweet-commits.js << EOF
|
||||
${{ toJSON(github.event) }}
|
||||
EOF
|
||||
env:
|
||||
CONSUMER_KEY: ${{ secrets.CONSUMER_KEY }}
|
||||
CONSUMER_SECRET: ${{ secrets.CONSUMER_SECRET }}
|
||||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
|
29
Meta/tweet-commits.js
Normal file
29
Meta/tweet-commits.js
Normal 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);
|
||||
}
|
||||
}
|
||||
})();
|
Loading…
Reference in a new issue