martinthomson / i-d-template

A template for IETF internet draft git repositories
Other
212 stars 183 forks source link

Tweet new drafts #272

Closed mnot closed 2 years ago

mnot commented 3 years ago

If submission is successful, it'd be nice to be able to tweet about it automagically.

The tweeting part is easy enough, but figuring out what to tweet is harder; from a quick look, it doesn't appear that even the tag name is available to GitHub Actions as it sits.

mnot commented 3 years ago

For later use:

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

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 myTweet = process.argv[2]
    await tweet(myTweet)
  } catch (err) {
    console.error(err)
  }
})()
martinthomson commented 3 years ago

The tag is available via ${{ github.ref }}. You have to strip refs/tags/ from the front.

martinthomson commented 2 years ago

For managing secrets: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-organization https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow

mnot commented 2 years ago

In the meantime we've been doing this by polling the data tracker api with https://github.com/ietf-github-services/datatracker-tweet

It's certainly possible to hook it in here, but doing it from data tracker allows tweeting other document actions too...

mnot commented 2 years ago

Closing as OBE