-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from shivam-Purohit/twitterapi
Auto Twitter Post On release #1825
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: publish-to-twitter | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tweet: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install tweepy | ||
- name: Run tweet script | ||
uses: ./ | ||
with: | ||
status: publish to twitter | ||
api_key: ${{ secrets.TWITTER_API_KEY }} | ||
api_key_secret: ${{ secrets.TWITTER_API_KEY_SECRET }} | ||
access_token: ${{ secrets.TWITTER_ACCESS_TOKEN }} | ||
access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
# twitter_post | ||
Twitter Post Action Repo | ||
|
||
## Example usage | ||
|
||
```yaml | ||
name: publish-to-twitter | ||
on: [release] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install tweepy | ||
- name: Publish tweet | ||
uses: intelowlproject/twitter-post | ||
with: | ||
status: Add publish notes here | ||
api_key: ${{ secrets.TWITTER_API_KEY}} | ||
api_key_secrets: ${{ secrets.TWITTER_API_KEY_SECRET}} | ||
access_token: ${{ secrets.TWITTER_ACCESS_TOKEN}} | ||
access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: publish-to-twitter | ||
description: posts tweets on Twitter | ||
author: IntelOwl | ||
|
||
inputs: | ||
api_key: | ||
description: "API key" | ||
required: true | ||
api_key_secret: | ||
description: "API key secret" | ||
required: true | ||
access_token: | ||
description: "Consumer access token" | ||
required: true | ||
access_token_secret: | ||
description: "Consumer access token secret" | ||
required: true | ||
status: | ||
description: "Status to be published to Twitter" | ||
required: true | ||
|
||
outputs: | ||
title: | ||
description: "Post's title" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install tweepy | ||
shell: bash | ||
|
||
- name: Run tweet script | ||
run: python3 publish.py ${{ inputs.api_key }} ${{ inputs.api_key_secret }} ${{ inputs.access_token }} ${{ inputs.access_token_secret }} "${{ inputs.status }}" | ||
shell: bash | ||
|
||
branding: | ||
icon: "message-circle" | ||
color: "blue" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import tweepy | ||
import os | ||
import sys | ||
|
||
api_key = sys.argv[1] | ||
api_key_secret = sys.argv[2] | ||
access_token = sys.argv[3] | ||
access_token_secret = sys.argv[4] | ||
status = sys.argv[5] | ||
|
||
client = tweepy.Client( | ||
consumer_key=api_key, | ||
consumer_secret=api_key_secret, | ||
access_token=access_token, | ||
access_token_secret=access_token_secret | ||
) | ||
|
||
tweet_content = status | ||
client.create_tweet(text = tweet_content) |