{"id":16146529,"url":"https://github.com/voxpelli/node-github-publish","last_synced_at":"2026-03-12T00:03:52.283Z","repository":{"id":34503290,"uuid":"38444253","full_name":"voxpelli/node-github-publish","owner":"voxpelli","description":"Publishes a file to a repository through the GitHub Contents API","archived":false,"fork":false,"pushed_at":"2025-08-03T21:31:56.000Z","size":99,"stargazers_count":26,"open_issues_count":11,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-03T22:56:39.710Z","etag":null,"topics":["api-wrapper","crud","github-api","node-js"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voxpelli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["voxpelli"]}},"created_at":"2015-07-02T16:35:09.000Z","updated_at":"2025-02-01T18:54:19.000Z","dependencies_parsed_at":"2023-01-15T07:30:57.665Z","dependency_job_id":"eaf7f9f8-9488-478c-96b3-58c82a24e90f","html_url":"https://github.com/voxpelli/node-github-publish","commit_stats":{"total_commits":125,"total_committers":5,"mean_commits":25.0,"dds":"0.33599999999999997","last_synced_commit":"51da206dfe5740d84580461ef9c03e1ca52e3269"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/voxpelli/node-github-publish","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fnode-github-publish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fnode-github-publish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fnode-github-publish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fnode-github-publish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voxpelli","download_url":"https://codeload.github.com/voxpelli/node-github-publish/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voxpelli%2Fnode-github-publish/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274907086,"owners_count":25371814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","crud","github-api","node-js"],"created_at":"2024-10-10T00:20:26.526Z","updated_at":"2026-03-12T00:03:52.234Z","avatar_url":"https://github.com/voxpelli.png","language":"JavaScript","funding_links":["https://github.com/sponsors/voxpelli"],"categories":[],"sub_categories":[],"readme":"# GitHub Publish\n\n[![npm version](https://img.shields.io/npm/v/github-publish.svg?style=flat)](https://www.npmjs.com/package/github-publish)\n[![npm downloads](https://img.shields.io/npm/dm/github-publish.svg?style=flat)](https://www.npmjs.com/package/github-publish)\n[![Module type: ESM](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![Types in JS](https://img.shields.io/badge/types_in_js-yes-brightgreen)](https://github.com/voxpelli/types-in-js)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-7fffff?style=flat\u0026labelColor=ff80ff)](https://github.com/neostandard/neostandard)\n[![Follow @voxpelli@mastodon.social](https://img.shields.io/mastodon/follow/109247025527949675?domain=https%3A%2F%2Fmastodon.social\u0026style=social)](https://mastodon.social/@voxpelli)\n\nPublishes a file to a repository through the GitHub Contents API\n\n## Installation\n\n### NPM\n```bash\nnpm install github-publish\n```\n\n## Current status\n\n**Stable, but not feature complete**\n\nCurrently missing support for deletes.\n\n## Usage\n\n```javascript\nimport { GitHubPublisher } from 'github-publish';\n\nconst publisher = new GitHubPublisher('token123', 'voxpelli', 'voxpelli.github.com');\n\nconst result = await publisher.publish('_post/2015-07-17-example-post.md', 'file content');\n\n// If \"result\" is truthy then the post was successfully published\n```\n\n## Classes\n\n* **GitHubPublisher(token, username, repo, [branch])** – creates a publisher object with an [access token](https://developer.github.com/v3/#authentication) for the GitHub API, the `username` of the owner of the repository to publish to and the name of the repository itself as `repo`.\n\n## `GitHubPublisher` methods\n\n* **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\n* **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).\n\n## `publish()` options\n\n* **force** – whether to replace any pre-existing file no matter what\n* **message** – a custom commit message. Default is `new content`\n* **sha** – the sha of an existing file that one wants to replace\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Fnode-github-publish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoxpelli%2Fnode-github-publish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoxpelli%2Fnode-github-publish/lists"}