Utility class for making changes to a repository from a GitHub Action.
npm install --save commit-from-action@^2.0.6
yarn add commit-from-action@^2.0.6
import CommitManager from "commit-from-action"
import {writeFile} from "fs/promises"
await writeFile("abc.txt", "abc")
const commitManager = new CommitManager
try {
await commitManager.commit("Added file abc.txt")
await commitManager.push()
} catch (error) {
console.error(error)
} finally {
// Does some cleaning, should be called regardless of whether commit and push are successful or not.
await commitManager.finalize()
}
Type | Default | Info | |
---|---|---|---|
autoApprove | boolean | true | If true, the created pull request will be automatically approved and merged. |
autoRemoveBranch | boolean | true | If true, the created branch will be automatically deleted. Good for avoiding mess. |
branch | string | randomly generated | Name of the temporary branch. If this is explicitly set, option `branchPrefix` is ignored. |
branchPrefix | string | "action-" | Starting string of the temporary branch's name. The rest of it will be randomly generated. |
commitMessage | string | "Modified repository in GitHub Action" | Default commit message to use, if commitManager.commit() is called without an argument. |
githubTokenInputName | string | "githubToken" | The key of your action's input that passes the user's GitHub token. |
ignoreFiles | string[] | [] | List of globs of files not to commit. |
mergeMessage | string | "Automatically merged commits from pull {pullNumber}" | Commit message of the pull request's merge. |
pullRequestBody | string | "Hewwo!" | Description of the automatically created pull request. |
pullRequestTitle | string | "Automatic changes from GitHub Action" | Title of the automatically created pull request. |
Development hints for maintaining and improving commit-from-action
Setting up:
git clone git@github.com:jaid/commit-from-action.git
cd commit-from-action
npm install
MIT License
Copyright © 2021, Jaid <jaid.jsx@gmail.com> (/~https://github.com/jaid)