DEV Community

[Comment from a deleted post]
Collapse
 
zwacky profile image
Simon Wicki

This is inspiring me to use the gist with other things like changelogs or releases, that's really sweet! Thanks for the post

Collapse
 
daviddalbusco profile image
David Dal Busco • Edited

That's a genius idea @zwacky 🀯

Something like following (not tested) would tweet the release notes

const {TwitterClient} = require('twitter-api-client');
const fetch = require('node-fetch');

const tweet = async (status) => {
  const twitterClient = new TwitterClient({
    apiKey: process.env.TWITTER_API_KEY,
    apiSecret: process.env.TWITTER_API_SECRET,
    accessToken: process.env.TWITTER_API_ACCESS_TOKEN,
    accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
  });

  await twitterClient.tweets.statusesUpdate({status});
};

(async () => {
  try {
    const {body} = await fetch
          `https://api.github.com/repos/deckgo/deckdeckgo/releases/latest`;

    await tweet(body);
  } catch (err) {
    console.error(err);
  }
})();
Enter fullscreen mode Exit fullscreen mode