Skip to content
Octokit plugin to create/update multiple files at once
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
create-or-update-files.js
create-or-update-files.test.js
index.js
package-lock.json
package.json

README.md

octokit-commit-multiple-files

This plugin is an alternative to using octokit.repos.createOrUpdateFile which allows you to edit the contents of a single file.

Installation

npm install octokit-commit-multiple-files --save

Usage

This plugin accepts owner, repo, path, branch and message like .createOrUpdateFile (Octokit Docs).

If the branch provided does not exist, the plugin will error. To automatically create it, set createBranch to true. You may provide a base branch if you choose to do this, or the plugin will use the repo's default branch as the base.

In addition, it accepts changes which is an array of objects containing a path and the file contents.

const Octokit = require("@octokit/rest").plugin(
  require("octokit-commit-multiple-files")
);
const octokit = new Octokit();

const branchName = await octokit.repos.createOrUpdateFiles({
  owner,
  repo,
  branch,
  createBranch,
  message,
  changes: [
    {
      path: "test.md",
      contents: "One"
    },
    {
      path: "test2.md",
      contents: "Two"
    }
  ]
})
You can’t perform that action at this time.