If you find this useful, please consider supporting my work with a donation.
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.
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 thepublic_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.
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.
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 }}
- Ensure you have Node.js 12+ installed
- Fork and clone this repository
- Run
npm install
- Run
npm test
to run tests
This code is licensed under the Apache 2.0 License (see LICENSE for details).
Copyright Human Who Codes LLC. All rights reserved.