npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jesses/circle-github-bot

v2.1.0

Published

CircleCI comments on github

Downloads

176

Readme

Now compatible with Circle 2.0

Circle Github Bot

This library helps you submit a comment on the PR from inside your CircleCI build and link to a static artifact from the build.

When reviewing a PR on github, it's useful to read the code but even more useful to test out the code on that branch in a live working web app.

See an example PR on this github repo https://github.com/themadcreator/circle-github-bot/pull/3

It works like so:

  1. Someone creates a pull request on your github project
  2. This triggers a CircleCI build, which:
  3. Runs tests
  4. Builds your static demo site
  5. Runs your demo.js script, submitting a comment back to the PR
  6. A comment shows up on the github PR
  7. CircleCI "collects" the artifacts from the build and makes them available on the web
  8. You click the link on the PR and see the static site!

Setting Up Demo Comments on PRs

Write the Bot Comment Script

Create a demo.js script using this library to post a comment on github referencing the current PR.

Example:

#!/usr/bin/env node

const bot = require("circle-github-bot").create();

bot.comment(`
<h3>${bot.env.commitMessage}</h3>
Demo: <strong>${bot.artifactLink('demo/index.html', 'demo')}</strong>
`);

With that "shebang" at the top, you can chmod +x your script file from the command line to make it self-executable.

Integrate CircleCI into your Repo

  1. Add CircleCI service integration to your github project in your repo's project settings
  2. Settings > Integrations & Services > Services
  3. Once CircleCI is following your github project, it will add its own deploy key to this repo
  4. Add .circleci/config.yml file to the root of your repo
  5. Store your demo/ directory as a build artifact
  6. Include job that runs your demo script
version: 2

jobs:
  demo:
    docker:
      - image: circleci/node:8.10.0
    steps:
      - checkout
      - run: npm install
      - run: npm run build
      - run: ./demo.js
      - store_artifacts:
          path: demo

workflows:
  version: 2
  your-project-workflow:
    jobs:
      - demo

Add Github Auth Token to CircleCI Environment

Make sure your script can actually post the comment to github

  1. Go to your github profile settings
  2. Add a new OAuth token under "Developer Settings" -> "Personal access tokens"
  3. The only permissions required are those needed to comment on your repo. For example public_repo is enough for commenting on a public repository.
  4. Once created, add the token string to your CircleCI build's environment variables
  5. Build Settings > Environment variables
  6. Name the variable "GH_AUTH_TOKEN"

Require CircleCI Build for PRs

Optional, but helpful. This makes sure your builds actually pass before a PR can be submitted.

  1. Set your main branch (e.g. master) to protected
  2. Enabled "required status checks"
  3. Select your "ci/circleci" workflow jobs as a required status checks