File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : publish-to-twitter
2+
3+ on :
4+ workflow_dispatch :
5+
6+ jobs :
7+ tweet :
8+ runs-on : ubuntu-latest
9+ steps :
10+ - name : Checkout code
11+ uses : actions/checkout@v3
12+
13+ - name : Set up Python
14+ uses : actions/setup-python@v3
15+ with :
16+ python-version : 3.x
17+
18+ - name : Install dependencies
19+ run : |
20+ pip install tweepy
21+
22+ - name : Run tweet script
23+ uses : ./
24+ with :
25+ status : publish to twitter
26+ api_key : ${{ secrets.TWITTER_API_KEY }}
27+ api_key_secret : ${{ secrets.TWITTER_API_KEY_SECRET }}
28+ access_token : ${{ secrets.TWITTER_ACCESS_TOKEN }}
29+ access_token_secret : ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
Original file line number Diff line number Diff line change 11# twitter_post
22Twitter Post Action Repo
3+
4+ ## Example usage
5+
6+ ``` yaml
7+ name : publish-to-twitter
8+ on : [release]
9+
10+ jobs :
11+ build :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v3
16+
17+ - name : Set up Python
18+ uses : actions/setup-python@v3
19+ with :
20+ python-version : 3.x
21+
22+ - name : Install dependencies
23+ run : |
24+ pip install tweepy
25+
26+ - name : Publish tweet
27+ uses : intelowlproject/twitter-post
28+ with :
29+ status : Add publish notes here
30+ api_key : ${{ secrets.TWITTER_API_KEY}}
31+ api_key_secrets : ${{ secrets.TWITTER_API_KEY_SECRET}}
32+ access_token : ${{ secrets.TWITTER_ACCESS_TOKEN}}
33+ access_token_secret : ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET}}
34+ ` ` `
Original file line number Diff line number Diff line change 1+ name : publish-to-twitter
2+ description : posts tweets on Twitter
3+ author : IntelOwl
4+
5+ inputs :
6+ api_key :
7+ description : " API key"
8+ required : true
9+ api_key_secret :
10+ description : " API key secret"
11+ required : true
12+ access_token :
13+ description : " Consumer access token"
14+ required : true
15+ access_token_secret :
16+ description : " Consumer access token secret"
17+ required : true
18+ status :
19+ description : " Status to be published to Twitter"
20+ required : true
21+
22+ outputs :
23+ title :
24+ description : " Post's title"
25+
26+ runs :
27+ using : " composite"
28+ steps :
29+ - name : Checkout code
30+ uses : actions/checkout@v2
31+
32+ - name : Set up Python
33+ uses : actions/setup-python@v2
34+ with :
35+ python-version : 3.x
36+
37+ - name : Install dependencies
38+ run : |
39+ pip install tweepy
40+ shell : bash
41+
42+ - name : Run tweet script
43+ run : python3 publish.py ${{ inputs.api_key }} ${{ inputs.api_key_secret }} ${{ inputs.access_token }} ${{ inputs.access_token_secret }} "${{ inputs.status }}"
44+ shell : bash
45+
46+ branding :
47+ icon : " message-circle"
48+ color : " blue"
Original file line number Diff line number Diff line change 1+ import tweepy
2+ import os
3+ import sys
4+
5+ api_key = sys .argv [1 ]
6+ api_key_secret = sys .argv [2 ]
7+ access_token = sys .argv [3 ]
8+ access_token_secret = sys .argv [4 ]
9+ status = sys .argv [5 ]
10+
11+ client = tweepy .Client (
12+ consumer_key = api_key ,
13+ consumer_secret = api_key_secret ,
14+ access_token = access_token ,
15+ access_token_secret = access_token_secret
16+ )
17+
18+ tweet_content = status
19+ client .create_tweet (text = tweet_content )
You can’t perform that action at this time.
0 commit comments