You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-9
Original file line number
Diff line number
Diff line change
@@ -27,14 +27,6 @@ Add a step like this to your workflow:
27
27
# Default: depends on the default_author input
28
28
author_email: mail@example.com
29
29
30
-
# The name of the branch to use, if different from the one that triggered the workflow.
31
-
# Default: the branch that triggered the run
32
-
branch: some-branch
33
-
34
-
# How the action should behave when the targeted branch is missing: "create" will create a new one on the remote, "throw" will exit
35
-
# Default: throw
36
-
branch_mode: create
37
-
38
30
# The name of the custom committer you want to use, if different from the author of the commit.
39
31
# Default: the name of the author (set with either author_name or default_author)
40
32
committer_name: Committer Name
@@ -58,6 +50,10 @@ Add a step like this to your workflow:
58
50
# Default: 'Commit from GitHub Actions (name of the workflow)'
59
51
message: 'Your commit message'
60
52
53
+
# If this input is set, the action will push the commit to a new branch with this name.
54
+
# Default: ''
55
+
new_branch: custom-new-branch
56
+
61
57
# The way the action should handle pathspec errors from the add and remove commands. Three options are available:
62
58
# - ignore -> errors will be logged but the step won't fail
63
59
# - 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',
101
97
102
98
### Pushing
103
99
104
-
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:
100
+
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:
105
101
106
102
- `true`: this is the default value, it will behave as usual.
107
103
- `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
110
106
111
107
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`.
112
108
109
+
### Creating a new branch
110
+
111
+
If you want the action to commit in a new branch, you can use the `new_branch` input.
112
+
113
+
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.
114
+
115
+
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:
116
+
117
+
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.
118
+
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.
119
+
113
120
### Tagging
114
121
115
122
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).
0 commit comments