diff --git a/README.md b/README.md index 7aa811b..4deb833 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,6 @@ Add a step like this to your workflow: # Default: depends on the default_author input author_email: mail@example.com - # The name of the branch to use, if different from the one that triggered the workflow. - # Default: the branch that triggered the run - branch: some-branch - - # How the action should behave when the targeted branch is missing: "create" will create a new one on the remote, "throw" will exit - # Default: throw - branch_mode: create - # The name of the custom committer you want to use, if different from the author of the commit. # Default: the name of the author (set with either author_name or default_author) committer_name: Committer Name @@ -58,6 +50,10 @@ Add a step like this to your workflow: # Default: 'Commit from GitHub Actions (name of the workflow)' message: 'Your commit message' + # If this input is set, the action will push the commit to a new branch with this name. + # Default: '' + new_branch: custom-new-branch + # The way the action should handle pathspec errors from the add and remove commands. Three options are available: # - ignore -> errors will be logged but the step won't fail # - exitImmediately -> the action will stop right away, and the step will fail @@ -101,7 +97,7 @@ You can also use JSON or YAML arrays (e.g. `'["first", "second"]'`, `"['first', ### Pushing -By default the action runs the following command: `git push origin ${branch input} --set-upstream`. You can use the `push` input to modify this behavior, here's what you can set it to: +By default the action runs the following command: `git push origin ${new_branch input} --set-upstream`. You can use the `push` input to modify this behavior, here's what you can set it to: - `true`: this is the default value, it will behave as usual. - `false`: this prevents the action from pushing at all, no `git push` command is run. @@ -110,6 +106,17 @@ By default the action runs the following command: `git push origin ${branch inpu One way to use this is if you want to force push to a branch of your repo: you'll need to set the `push` input to, for example, `origin yourBranch --force`. +### Creating a new branch + +If you want the action to commit in a new branch, you can use the `new_branch` input. + +Please note that if the branch exists, the action will still try push to it, but it's possible that the push will be rejected by the remote as non-straightforward. + +If that's the case, you need to make sure that the branch you want to commit to is already checked out before you run the action. If you want to commit files "across different branches", here are two ways to do it: + +1. You can check them out in two different directories, generate your files, move them to your destination and then run `add-and-commit` in the destination directory using the `cwd` input. +2. You can manually commit those files with `git` commands as you would on your machine. There are several ways to do this depending on the scenario. One of them if to stash your changes, checkout the destination branch, and popping the stash. You can then use the `add-and-commit` action as usual. Please note that this is just an example and may not work for you, since your use case may be different. + ### Tagging You can use the `tag` option to enter the arguments for a `git add` command. In order for the action to isolate the tag name from the rest of the arguments, it should be the first word not preceded by an hyphen (e.g. `-a tag-name -m "some other stuff"` is ok).