Automatically post a tweet when publishing a release on GitHub

Feb 15, 2021Β·

2 min read

I often post a tweet on Twitter whenever I publish a new release of one of my open-source projects. This task, as many others, can be automated with GitHub actions.

First, I signed up on and then created a Twitter application. This allows me to programmatically authenticate to the Twitter API and send a tweet. The process is straightforward with one little caveat. Per default the app gets created with read-only access. Change permission to Read and Write before you generate access token & secret.


Then I store the Twitter API key & secret as well as the access key & secret as repository secrets in the GitHub repository for which I want to send tweets.


Finally I can define the GitHub workflow by leveraging the existing, reusable GitHub action,

Here is the final workflow:

name: tweet-release
    types: [published]
    runs-on: ubuntu-latest    
      - uses: ethomson/send-tweet-action@v1
          status: "New ${{ }} release ${{ github.event.release.tag_name }} at ${{ github.event.release.html_url }}"
          consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
          consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
          access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
          access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

And this is the tweet, which was automatically sent when I created release 1.0.0 for repository



Did you find this article valuable?

Support Marco Eidinger by becoming a sponsor. Any amount is appreciated!