Now compatible with Circle 2.0
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:
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.
.circleci/config.yml
file to the root of your repo
demo/
directory as a build artifactversion: 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
Make sure your script can actually post the comment to github
public_repo
is enough for commenting on a public repository.Optional, but helpful. This makes sure your builds actually pass before a PR can be submitted.