Skip to content

Commit 12febc4

Browse files
committed
Use git add
1 parent de8a121 commit 12febc4

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Add a step like this to your workflow:
1212
```yaml
1313
- uses: EndBug/add-and-commit@v2 # You can change this to use a specific version
1414
with:
15+
# The arguments for the git add command (see the paragraph below for more info)
16+
# Default: '.'
17+
add: 'src'
18+
1519
# The name of the user that will be displayed as the author of the commit
1620
# Default: author of the commit that triggered the run
1721
author_name: Your Name
@@ -32,15 +36,7 @@ Add a step like this to your workflow:
3236
# Default: 'Commit from GitHub Actions'
3337
message: 'Your commit message'
3438

35-
# The path to stage files from
36-
# Default: '.'
37-
path: 'src'
38-
39-
# The pattern that mathces file names
40-
# Default: '*.*'
41-
pattern: "*.js"
42-
43-
# The files to remove
39+
# The arguments for the git rm command (see the paragraph below for more info)
4440
# Default: ''
4541
remove: "./dir/old_file.js"
4642

@@ -54,9 +50,13 @@ Add a step like this to your workflow:
5450
The only `env` variable required is the token for the action to run: GitHub generates one automatically, but you need to pass it through `env` to make it available to actions. You can find more about `GITHUB_TOKEN` [here](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret).
5551
With that said, you can just copy the example line and don't worry about it. If you do want to use a different token you can pass that in, but I wouldn't see any possible advantage in doing so.
5652

53+
### Adding files:
54+
55+
The action adds files using a regular `git add` command, so you can put every kind of argument in the `add` option. For example, if you don't want it to use a recursive behavior: `$(find . -maxdepth 1 -name *.js)`
56+
5757
### Deleting files:
5858

59-
You can delete files with the `remove` option: that runs a `git remove` command that will stage the files in the given path for removal. Please keep in mind that if the path is wrong the action will stop.
59+
You can delete files with the `remove` option: that runs a `git rm` command that will stage the files in the given path for removal. Please keep in mind that if the path is wrong the action will stop.
6060

6161
### Examples:
6262

@@ -86,13 +86,12 @@ jobs:
8686
run: eslint "src/**" --fix
8787
8888
- name: Commit changes
89-
uses: EndBug/add-and-commit@v2
89+
uses: EndBug/add-and-commit@v4
9090
with:
9191
author_name: Your Name
9292
author_email: [email protected]
9393
message: "Your commit message"
94-
path: "."
95-
pattern: "*.js"
94+
add: "*.js"
9695
env:
9796
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9897
```
@@ -118,11 +117,10 @@ jobs:
118117
- run: echo "123" > ./pathToRepo/file.txt
119118
120119
# ...and then use the action as you would normally do, but providing the path to the repo
121-
- uses: EndBug/add-and-commit@v2
120+
- uses: EndBug/add-and-commit@v4
122121
with:
123122
message: "Add the very useful text file"
124-
path: "."
125-
pattern: "*.txt"
123+
add: "*.txt"
126124
cwd: "./pathToRepo/"
127125
force: true
128126
env:

action.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ inputs:
2020
description: The message for the commit
2121
required: false
2222
default: Commit from GitHub Actions
23-
path:
24-
description: The path to stage files from
23+
add:
24+
description: Arguments for the git add command
2525
required: false
2626
default: "."
27-
pattern:
28-
description: The pattern that mathces file names
29-
required: false
30-
default: "*.*"
3127
remove:
32-
description: The files to remove
28+
description: Arguments for the git rm command
3329
required: false
3430
default: ""
3531

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "add-and-commit",
3-
"version": "2.3.0",
3+
"version": "4.0.0",
44
"description": "Add & commit files from a path directly from GitHub Actions",
55
"main": "lib/main.js",
66
"scripts": {

src/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EOF
2222

2323
add() {
2424
if $INPUT_FORCE; then f=-f; else f=; fi
25-
find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $f $x; done
25+
git add $INPUT_ADD $f
2626
}
2727

2828
remove() {

0 commit comments

Comments
 (0)