Asrin Dayananda


Twitter tweet bot using GitHub Actions

Twitter tweet bot using GitHub Actions

Update Twitter status automatically using GitHub Actions

Subscribe to my newsletter and never miss my upcoming articles

Log into your twitter account

Register as twitter dev

Once approved create a new app

  • Name your twitter bot
  • You should have keys now

  • Create new repo in github

  • Save your twitter keys to your GitHub repository secrets
  • Click on settings > secrets in your repository
  • Add the keys from your twitter app you created
  • Name them as close as twitter state so you can recall them later easily
  • eg.
  • Also create more keys by clicking new access token and secret and save all these values

  • Create new file in your GitHub repo like this path


Add below code to file

# This is a basic workflow to help you get started with Actions

name: TwitterBot

# Controls when the action will run. 
  # Triggers the workflow on push or pull request events but only for the main branch
    branches: [ main ]
    - cron: '0 16 * * *' 
  # Allows you to run this workflow manually from the Actions tab

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
  # This workflow contains a single job called "build"
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    #Tweet to twitter
      - name: TweetToTwitter
        uses: InfraWay/tweet-action@v1.0.1
          status: Test Tweet
          api_key: ${{ secrets.TWITTER_API_KEY }}
          api_key_secret: ${{ secrets.API_KEY_SECRET }}
          access_token: ${{ secrets.BEARER_TOKEN }}
          access_token_secret: ${{ secrets.BEARER_TOKEN }}
  • Commit your changes

  • Click actions and see your GitHub action build

  • If you get this error image.png

  • Your keys arnt set correctly
  • Re generate your keys in twitter and reset them in your github repository secrets


  • Re run job or add empty space commit to your yml file and push commit. The action is set to build on push at the moment.

  • If you get this error

    Error: {"request":"\/1.1\/statuses\/update.json","error":"Read-only application cannot POST."}
  • Set your twitter app to be able to write posts
  • Twitter App Settings > App permissions > Edit


  • Set to read and write


  • You will have to regenerate all your keys and save them to your GitHub Secrets

  • If you see success your github action will succeed


  • And you will have a successful tweet !😵


Hope this works for you. Let me know if you get stuck.

Happy Coding, Asrin

If this helped you consider buying me a coffee :)


Did you find this article valuable?

Support Asrin Dayananda by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
Share this