0.1.0 • Published 4 years ago

@humanwhocodes/github-comment v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

GitHub Comment CLI

by Nicholas C. Zakas

Node CI

If you find this useful, please consider supporting my work with a donation.

Description

A simple CLI for posting comments to GitHub. This is intended for use in CI systems such as GitHub actions in order to enable to Twitter notifications of important events.

Usage

You must have Node.js to use this package.

Next, define your environment variable:

  • GITHUB_TOKEN - your GitHub access token. Make sure you have at least the public_repo scope to allow commenting on both issues and pull requests.

The CLI will not work without this environment variable.

Then, you can run the CLI and pass a message on the command line using npx:

$ npx @humanwhocodes/github-comment owner/repo#1234 "Hello from the command line!"

Where owner/repo#1234 is the issue or pull request that you'd like to comment on.

Testing with dotenv

If you'd like to test with dotenv, define an additional environment variable GHC_DOTENV=1 before executing the CLI. This will cause a local .env file to be read before executing.

Using in a GitHub Workflow

Be sure to set up GitHub secrets for each environment variable. Then, you can configure a job like this:

jobs:
  tweet:
    name: Comment Something
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: 'npx @humanwhocodes/github-comment owner/repo#1234 "Your comment text"'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Developer Setup

  1. Ensure you have Node.js 12+ installed
  2. Fork and clone this repository
  3. Run npm install
  4. Run npm test to run tests

License and Copyright

This code is licensed under the Apache 2.0 License (see LICENSE for details).

Copyright Human Who Codes LLC. All rights reserved.