Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xorilog/twitter-action

Post tweet using this action !
https://github.com/xorilog/twitter-action

github-actions go golang twitter

Last synced: 7 days ago
JSON representation

Post tweet using this action !

Awesome Lists containing this project

README

        

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.
```