Repository: siddharthkp/github-build
Branch: main
Commit: 723b1cce3fef
Files: 8
Total size: 6.1 KB
Directory structure:
gitextract_xr25jwcj/
├── .github/
│ └── workflows/
│ └── test.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── index.js
├── package.json
└── test.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/test.yml
================================================
name: Node.js CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
cache: 'npm'
- run: npm ci
- run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} SHA=${{github.sha}} npm test
================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
================================================
FILE: .travis.yml
================================================
dist: trusty
language: node_js
node_js:
- "node"
- "6"
cache:
directories:
- node_modules
notifications:
email: false
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 Siddharth Kshetrapal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
<p align="center">
<img src="https://raw.githubusercontent.com/siddharthkp/github-build/master/art/logo.png" height="100px"/>
<br><br>
<b>Github builds/checks for CI</b>
<br><br>
</p>
<p>
<img src="https://raw.githubusercontent.com/siddharthkp/github-build/master/art/commit.png" height="200px"/>
<br>
<img src="https://raw.githubusercontent.com/siddharthkp/github-build/master/art/pull_request.png" height="250px"/>
</p>
[](https://lima.codeclimate.com/github/siddharthkp/github-build)
[](https://snyk.io/test/github/siddharthkp/github-build)
#### Install
```
npm install github-build --save
```
#### Usage
```js
const Build = require('github-build')
const data = {
repo: 'siddharthkp/github-build', // (author/repo)
sha: '6954e71d46be1ae9b0529aae6e00b64d7a1023d4', // (commit sha)
token: 'secret', // (github oauth token: https://developer.github.com/v3/oauth)
label: 'my CI service',
description: 'checking some stuff',
url: 'http://my-ci-service.com/builds/1', // details url
}
/* Create a build */
const build = new Build(data)
/* When you call start, a pending status get's added on github (returns a promise) */
build.start()
/* Run your tests */
/* If things go well, call pass, it will mark change the status to success ✅ (returns a promise) */
build.pass()
/* Or if the tests fail, mark this build as failed ❌ (returns a promise) */
build.fail()
/* If you could not run the tests because of incorrect config, just error out the build (returns a promise) */
build.error() // use when build errors out (returns a promise)
```
If you like it then [you should put a ⭐️ on it](https://www.youtube.com/watch?v=4m1EFMoRFvY)
#### License
MIT © siddharthkp
================================================
FILE: index.js
================================================
const axios = require('axios')
class Build {
constructor(meta) {
meta.context = meta.label
meta.target_url = meta.url
this.meta = meta
}
start (message, url) {return update(this.meta, message, url, 'pending')}
pass (message, url) {return update(this.meta, message, url, 'success')}
fail (message, url) {return update(this.meta, message, url, 'failure')}
error (message, url) {return update(this.meta, message, url, 'error')}
}
const update = (build, message, url, status) => new Promise((resolve, reject) => {
axios({
method: 'POST',
url: `https://api.github.com/repos/${build.repo}/statuses/${build.sha}`,
responseType: 'json',
data: {
state: status,
target_url: url || build.url,
description: message || build.description,
context: build.context
},
headers: {'Authorization': `token ${build.token}`}
})
.then(({status, data}) => resolve({status, data}))
.catch(({response = {status: 500}}) => reject({
status: response.status,
error: response.data
}))
})
module.exports = Build;
================================================
FILE: package.json
================================================
{
"name": "github-build",
"version": "1.2.4",
"description": "Github builds/checks for CI",
"main": "index.js",
"scripts": {
"test": "node test"
},
"keywords": [
"github",
"build",
"checks",
"ci"
],
"homepage": "https://github.com/siddharthkp/github-build",
"repository": {
"type": "git",
"url": "git+https://github.com/siddharthkp/github-build.git"
},
"author": "siddharthkp",
"license": "MIT",
"dependencies": {
"axios": "1.6.0"
},
"files": [
"index.js"
]
}
================================================
FILE: test.js
================================================
const Build = require('./index')
const data = {
repo: 'siddharthkp/github-build',
sha: process.env.SHA || process.env.TRAVIS_PULL_REQUEST_SHA || '4391039e9c506a1702ee7971cda4613ca5da2d69',
token: process.env.GITHUB_TOKEN,
label: 'github-build',
description: 'Running some tests'
}
const build = new Build(data)
build.start()
setTimeout(() => build.pass('Tests passed!', 'https://example.com'), 5000)
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Promise: ')
console.log(reason, p)
process.exit(1)
})
gitextract_xr25jwcj/ ├── .github/ │ └── workflows/ │ └── test.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── index.js ├── package.json └── test.js
SYMBOL INDEX (6 symbols across 1 files)
FILE: index.js
class Build (line 3) | class Build {
method constructor (line 4) | constructor(meta) {
method start (line 9) | start (message, url) {return update(this.meta, message, url, 'pending')}
method pass (line 10) | pass (message, url) {return update(this.meta, message, url, 'success')}
method fail (line 11) | fail (message, url) {return update(this.meta, message, url, 'failure')}
method error (line 12) | error (message, url) {return update(this.meta, message, url, 'error')}
Condensed preview — 8 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (7K chars).
[
{
"path": ".github/workflows/test.yml",
"chars": 372,
"preview": "name: Node.js CI\n\non:\n push:\n branches: [ \"main\" ]\n pull_request:\n branches: [ \"main\" ]\n\njobs:\n test:\n\n runs"
},
{
"path": ".gitignore",
"chars": 578,
"preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n\n# Directory for instrumented libs generated by jscov"
},
{
"path": ".travis.yml",
"chars": 130,
"preview": "dist: trusty\nlanguage: node_js\nnode_js:\n - \"node\"\n - \"6\"\ncache:\n directories:\n - node_modules\nnotifications:\n ema"
},
{
"path": "LICENSE",
"chars": 1077,
"preview": "MIT License\n\nCopyright (c) 2017 Siddharth Kshetrapal\n\nPermission is hereby granted, free of charge, to any person obtain"
},
{
"path": "README.md",
"chars": 1913,
"preview": "<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/siddharthkp/github-build/master/art/logo.png\" height=\"1"
},
{
"path": "index.js",
"chars": 1082,
"preview": "const axios = require('axios')\n\nclass Build {\n constructor(meta) {\n meta.context = meta.label\n meta.target_url = "
},
{
"path": "package.json",
"chars": 530,
"preview": "{\n \"name\": \"github-build\",\n \"version\": \"1.2.4\",\n \"description\": \"Github builds/checks for CI\",\n \"main\": \"index.js\",\n"
},
{
"path": "test.js",
"chars": 546,
"preview": "const Build = require('./index')\n\nconst data = {\n repo: 'siddharthkp/github-build',\n sha: process.env.SHA || process.e"
}
]
About this extraction
This page contains the full source code of the siddharthkp/github-build GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 8 files (6.1 KB), approximately 1.9k tokens, and a symbol index with 6 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.