Tweet via GitHub Actions.
- Create your Twitter App in developer.twitter.com.
- Generate Twitter API v1.1 tokens. (Not Twitter API v2)
- Set secrets
TWITTER_CONSUMER_API_KEY
,TWITTER_CONSUMER_API_SECRET_KEY
,TWITTER_ACCESS_TOKEN
,TWITTER_ACCESS_TOKEN_SECRET
in settings. - Create workflow YAML.
steps:
- name: Tweet
uses: snow-actions/[email protected]
with:
status: |
Released ${{ github.event.release.name }}
${{ github.event.release.html_url }}
env:
CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
CONSUMER_API_SECRET_KEY: ${{ secrets.TWITTER_CONSUMER_API_SECRET_KEY }}
ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
env:
CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
CONSUMER_API_SECRET_KEY: ${{ secrets.TWITTER_CONSUMER_API_SECRET_KEY }}
ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
steps:
- uses: actions/checkout@v3
- name: Tweet summary
id: summary
uses: snow-actions/[email protected]
with:
status: |
Released ${{ github.event.release.name }}
${{ github.event.release.html_url }}
media_paths: |
1st.png
2nd.png
- name: Tweet details
uses: snow-actions/[email protected]
with:
status: |
Additional information
in_reply_to_status_id: ${{ fromJSON(steps.summary.outputs.response).id_str }}
Authentication parameters.
name | required | description |
---|---|---|
CONSUMER_API_KEY | required | Consumer API key |
CONSUMER_API_SECRET_KEY | required | Consumer API secret key |
ACCESS_TOKEN | required | Access token |
ACCESS_TOKEN_SECRET | required | Access token secret |
See action.yml and Twitter API reference.
Request parameters.
name | required | description |
---|---|---|
status | required | The text of the status update. URL encode as necessary. t.co link wrapping will affect character counts. |
media_paths | optional | Upload media path(s). You may attach up to 4 photos, 1 animated GIF or 1 video in a Tweet. |
Size restrictions for uploading via API
- Image 5MB
- GIF 15MB
- Video 15MB (when using media_category=amplify)
Response.
name | description |
---|---|
response | Response JSON |
See ci.yml
ubuntu-*
windows-*
macos-*
self-hosted
- Any
The access token of Twitter API v2 has a time limit.
If the scope offline.access
is applied an OAuth 2.0 refresh token will be issued. With this refresh token, we obtain an access token. Secure storage is required to keep these tokens.