Skip to content
Publishes a file to a repository through the GitHub Contents API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.editorconfig Update dev dependencies Oct 23, 2016
.eslintignore Update dev dependencies Oct 23, 2016
.eslintrc Disallow var-definitions in code Oct 23, 2016
.gitignore
.travis.yml Tweak Travis tests Jun 6, 2018
CHANGELOG.md Update Changelog Jan 3, 2018
LICENSE Added LICENSE Oct 23, 2016
README.md Update readme Jun 6, 2018
index.js Breaking: retrieve() is correctly now decoded Jan 3, 2018
package.json
renovate.json Update renovate.json Jun 17, 2018

README.md

GitHub Publish

Build Status Coverage Status dependencies Status Known Vulnerabilities js-semistandard-style FOSSA Status

Publishes a file to a repository through the GitHub Contents API

Requirements

Requires at least Node.js 6.x

Installation

npm install github-publish --save

Current status

Stable, but not feature complete

Currently missing support for deletes.

Usage

var GitHubPublisher = require('github-publish');

var publisher = new GitHubPublisher('token123', 'voxpelli', 'voxpelli.github.com');

publisher.publish('_post/2015-07-17-example-post.md', 'file content').then(function (result) {
  // If "result" is truthy then the post was successfully published
});

Classes

  • GitHubPublisher(token, username, repo) – creates a publisher object with an access token for the GitHub API, the username of the owner of the repository to publish to and the name of the repository itself as repo.

GitHubPublisher methods

  • retrieve(filename) – returns a Promise that resolves with either an object containing the content and sha of the existing file or with false if no such file exists in the repository
  • publish(filename, content, [options]) – publishes the specified content as the filename to the repo of the publisher object. content should be either a string or a Buffer. Returns a Promise which resolves to the sha of the created object on success and to false on failure (failure is likely caused by a collision with a pre-existing file, as long as one haven't specified that it should be overridden).

publish() options

  • force – whether to replace any pre-existing file no matter what
  • message – a custom commit message. Default is new content
  • sha – the sha of an existing file that one wants to replace

License

FOSSA Status

You can’t perform that action at this time.