Skip to content

stdlib-js/metadata-tweet-action

Repository files navigation

Metadata Tweet Action

A GitHub action for automatically sending tweets based on commit metadata.

Example Workflow

# Workflow name:
name: Test GitHub Action

# Workflow triggers:
on:
  push:

# Workflow jobs:
jobs:
  test:
    # Define the type of virtual host machine on which to run the job:
    runs-on: ubuntu-latest

    # Define the sequence of job steps...
    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: |
          npm install
      - name: Extract metadata
        id: extract-metadata
        uses: stdlib-js/commit-metadata-action@v2
      - name: Process metadata and send tweets
        uses: stdlib-js/metadata-tweet-action@v2
        with:
          metadata: ${{ steps.extract-metadata.outputs.metadata }}
          TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
          TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
          TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
          TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

Inputs

  • metadata: (required) metadata object array as generated by the commit-metadata-action.

  • types: (optional) comma-separated list of types for which to generate tweets. Default: 'bugfix, feature, release'.

  • authors: (optional) file path to a JSON file containing a mapping from GitHub user names to Twitter handles.

    {
        "kgryte": "kgryte",
        "Planeshifter": "burckhap"
    }

    Default: './authors.json'.

  • rules: (optional) file path to a JSON file containing the rules for generating tweets for each type in types. For each type, the value should be an object whose keys are regular expression strings and whose values are corresponding replacement strings for each type.

    {
        "bugfix": {},
        "feature": {
    	    "/^[\\s\\S]*?adds? support ([\\s\\S]+)$/i": ":robot_face: [stdlib-bot]: Feature announcement! We've added support $1! Thanks, <author>! <url> #javascript #nodejs"
        },
        "release": {}
    }

    If a replacement string contains one or more placeholders demarcated by < >, the action replaces the placeholders with corresponding data from the metadata object. The <author> field is special, as the username subfield of the author metadata object is used to map to a Twitter handle. In the absence of a GitHub username to Twitter handle mapping, the action replaces the <author> placeholder with the GitHub author's name.

    If the value assigned to a regular expression string is an array, then the action samples one of the replacement strings from the list of replacement strings (note: this is useful when wanting to add variety to generated tweets).

    {
        "bugfix": {},
        "feature": {
    	    "/^[\\s\\S]*?adds? support ([\\s\\S]+)$/i": [
    		    ":robot_face: [stdlib-bot]: Feature announcement! We've added support $1! Thanks, <author>! <url> #javascript #nodejs",
    		    ":robot_face: [stdlib-bot]: New feature! <author> added support $1! <url> #javascript #nodejs"
    	    ]
        },
        "release": {}
    }

    Default: './rules.json'.

  • TWITTER_CONSUMER_KEY: (required) the consumer key for the Twitter application.

  • TWITTER_CONSUMER_SECRET: (required) the consumer secret for the Twitter application.

  • TWITTER_ACCESS_TOKEN: (required) the access token for the Twitter application.

  • TWITTER_ACCESS_TOKEN_SECRET: (required) the access token secret for the Twitter application.

License

See LICENSE.

Copyright

Copyright © 2021-2024. The Stdlib Authors.

About

A GitHub action for automatically sending tweets specified in a metadata array.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •