Skip to content

xorilog/twitter-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twitter-action

Auth

About the authentication see: https://developer.twitter.com/en/apps create an account, create an app @see https://apps.twitter.com/

retrieve the access tokens

@see https://developer.twitter.com/en/apps

Use Action

workflow "on push tag, tweet message" {
  on = "push"
  resolves = ["Advertise tweetosphere with a message"]
}

action "Advertise tweetosphere with a message" {
  uses = "xorilog/twitter-action@master"
  args = ["-message", "New version is out ! $GITHUB_REF"]
  secrets = ["TWITTER_CONSUMER_KEY", "TWITTER_CONSUMER_SECRET", "TWITTER_ACCESS_TOKEN", "TWITTER_ACCESS_SECRET"]
}

---
workflow "on push tag, tweet the content of a file" {
  on = "push"
  resolves = ["Advertise tweetosphere with the content of a file"]
}
action "Advertise tweetosphere with the content of a file" {
  uses = "xorilog/twitter-action@master"
  args = ["-file", "./my-tweet.yolo"]
  secrets = ["TWITTER_CONSUMER_KEY", "TWITTER_CONSUMER_SECRET", "TWITTER_ACCESS_TOKEN", "TWITTER_ACCESS_SECRET"]
}

---
workflow "on push tag, tweet message and file content" {
  on = "push"
  resolves = ["Advertise tweetosphere with a message and the content of a file"]
}
action "Advertise tweetosphere with a message and the content of a file" {
  uses = "xorilog/twitter-action@master"
  args = ["-message", "Here is the big news: ", "-file", "./my-tweet.yolo"]
  secrets = ["TWITTER_CONSUMER_KEY", "TWITTER_CONSUMER_SECRET", "TWITTER_ACCESS_TOKEN", "TWITTER_ACCESS_SECRET"]
}

Build

go get .
go build

Usage

Message

export TWITTER_CONSUMER_KEY=xxx
export TWITTER_CONSUMER_SECRET=xxx
export TWITTER_ACCESS_TOKEN=xxx
export TWITTER_ACCESS_SECRET=xxx
./twitter-action -message "Hello Twitter :)"

File

Read the content of the given file and send it as a tweet

export TWITTER_CONSUMER_KEY=xxx
export TWITTER_CONSUMER_SECRET=xxx
export TWITTER_ACCESS_TOKEN=xxx
export TWITTER_ACCESS_SECRET=xxx
./twitter-action -file ~/my-tweet.yolo

Both

This will concatenate the message and the content of the file given (handle the split yourself if needed)

export TWITTER_CONSUMER_KEY=xxx
export TWITTER_CONSUMER_SECRET=xxx
export TWITTER_ACCESS_TOKEN=xxx
export TWITTER_ACCESS_SECRET=xxx
./twitter-action -message "Here is the big news: " -file ~/my-tweet.yolo

Docker

# If building locally
docker build -t xorilog/twitter-action .

# else:
docker run --rm -e TWITTER_CONSUMER_KEY=${TWITTER_CONSUMER_KEY} \
       -e TWITTER_CONSUMER_SECRET=${TWITTER_CONSUMER_SECRET} \
       -e TWITTER_ACCESS_TOKEN=${TWITTER_ACCESS_TOKEN} \
       -e TWITTER_ACCESS_SECRET=${TWITTER_ACCESS_SECRET} \
       xorilog/twitter-action -message "Hello Twitter :)"

Test

./twitter-action -message "Here is the big news: " -file ~/my-tweet.yolo -dry"
2019/03/28 16:04:47 Logging in, creating client and updating status.
2019/03/28 16:04:47 Status updated with: Here is the big news: I am file my-tweet.yolo and this is my content.