Skip to content
edit

GitHub Action

Post Tweet V2 Action

v1.0 Latest version

Post Tweet V2 Action

edit

Post Tweet V2 Action

Post a tweet to Twitter during a GitHub Actions workflow with Twitter REST API for Version 2 endpoint

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Post Tweet V2 Action

uses: noweh/[email protected]

Learn more about this action in noweh/post-tweet-v2-action

Choose a version

Send a tweet from a GitHub Actions workflow

Badge Twitter MIT Licensed twitter

Post a Tweet from a GitHub Action workflow, with Twitter REST API for Version 2 endpoint.

Active your developer account

Before anything else, you must follow this tutorial.

  • Request approval for a developer account;
  • Once your developer account is approved, you will need to create a Project;
  • Enable read/write access for your Twitter app;
  • Generate Consumer Keys and Authentication Tokens;
  • Retrieve your Keys and Tokens from the Twitter Developer portal.

Secret Configuration

Configure the authentication keys and tokens for your Twitter app as secrets in your repository. I recommend using the TWITTER_CONSUMER_API_KEY, TWITTER_CONSUMER_API_SECRET, TWITTER_ACCESS_TOKEN, and TWITTER_ACCESS_TOKEN_SECRET secrets.

Workflow Usage

Configure your workflow to use noweh/post-tweet-v2-action@v1, and provide the tweet you want to send as the status input.

Provide the authentication keys and tokens for your Twitter app as the account-id and bearer-token inputs.

For example:

name: Send a Tweet
on: [push]
jobs:
  tweet:
    runs-on: ubuntu-latest
    steps:
      - uses: noweh/post-tweet-v2-action@v1
        with:
          message: "Hi, this is a test!"
          consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }}
          consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
          access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
          access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

Now whenever you push something to your repository, GitHub Actions will tweet on your behalf.