Giter Site home page Giter Site logo

tweeter's Introduction

B18275-08-Automating-Workflows-with-GitHub-Actions-Code-Files

The code files for chapter 8 of B18275 have been added on a separate repository of its own.

DevOps for Go Tweeter

The tweeter command line tool will send a tweet via Twitter.

Setup

You can use tweeter to send a tweet or to output the message to STDOUT. If you want to send a tweet, you will need to set up a Twitter application.

Setup With a Twitter Application

To send a tweet, you will need to create or use an existing Twitter account, create a Twitter application, and generate API credentials. All of this can be done through the Twitter Developer Portal.

Setup Without a Twitter Application

Some people may not want to set up a Twitter account. If you would like to use tweeter without sending tweets, use the --dry-run argument. This will cause the tool to write the message to STDOUT rather than sending the message to Twitter.

Inputs

  • --message Required the tweet message you would like to send
  • --apiKey the API key under Consumer Keys in the Twitter developer portal
  • --apiKeySecret the API key secret under Consumer Keys in the Twitter developer portal
  • --accessToken the access token under Authentication Tokens in the Twitter developer portal
  • --accessTokenSecret the access token secret under Authentications Tokens in the Twitter developer portal
  • --dryRun will skip authentication validation and sending the message to Twitter

Test

$ go test ./...
?   	github.com/devopsforgo/github-actions	[no test files]
ok  	github.com/devopsforgo/github-actions/pkg/tweeter	0.002s

Run Help

To see the command line arguments and descriptions, display the help.

$ go run . -h
Usage of /tmp/go-build3731631588/b001/exe/github-actions:
      --accessToken string         twitter access token
      --accessTokenSecret string   twitter access token secret
      --apiKey string              twitter api key
      --apiKeySecret string        twitter api key secret
      --dryRun                     if true, then a tweet will not be sent
      --message string             message you'd like to send to twitter
pflag: help requested
exit status 2

Run Without Sending a Tweet

The --dryRun argument will skip validation of the authentication arguments and output the message to STDOUT.

$ go run . --dryRun --message foo

Run Sending a Tweet

Without --dryRun specified, tweeter will send the --messsage argument as a Tweet.

$ go run . --message foo --apiKey 123 --apiKeySecret secret --accessToken token --accessTokenSecret secret

tweeter's People

Contributors

ehteshamz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.