Use git add
This commit is contained in:
30
README.md
30
README.md
@@ -12,6 +12,10 @@ Add a step like this to your workflow:
|
|||||||
```yaml
|
```yaml
|
||||||
- uses: EndBug/add-and-commit@v2 # You can change this to use a specific version
|
- uses: EndBug/add-and-commit@v2 # You can change this to use a specific version
|
||||||
with:
|
with:
|
||||||
|
# The arguments for the git add command (see the paragraph below for more info)
|
||||||
|
# Default: '.'
|
||||||
|
add: 'src'
|
||||||
|
|
||||||
# The name of the user that will be displayed as the author of the commit
|
# The name of the user that will be displayed as the author of the commit
|
||||||
# Default: author of the commit that triggered the run
|
# Default: author of the commit that triggered the run
|
||||||
author_name: Your Name
|
author_name: Your Name
|
||||||
@@ -32,15 +36,7 @@ Add a step like this to your workflow:
|
|||||||
# Default: 'Commit from GitHub Actions'
|
# Default: 'Commit from GitHub Actions'
|
||||||
message: 'Your commit message'
|
message: 'Your commit message'
|
||||||
|
|
||||||
# The path to stage files from
|
# The arguments for the git rm command (see the paragraph below for more info)
|
||||||
# Default: '.'
|
|
||||||
path: 'src'
|
|
||||||
|
|
||||||
# The pattern that mathces file names
|
|
||||||
# Default: '*.*'
|
|
||||||
pattern: "*.js"
|
|
||||||
|
|
||||||
# The files to remove
|
|
||||||
# Default: ''
|
# Default: ''
|
||||||
remove: "./dir/old_file.js"
|
remove: "./dir/old_file.js"
|
||||||
|
|
||||||
@@ -54,9 +50,13 @@ Add a step like this to your workflow:
|
|||||||
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).
|
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).
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
### Adding files:
|
||||||
|
|
||||||
|
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)`
|
||||||
|
|
||||||
### Deleting files:
|
### Deleting files:
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
### Examples:
|
### Examples:
|
||||||
|
|
||||||
@@ -86,13 +86,12 @@ jobs:
|
|||||||
run: eslint "src/**" --fix
|
run: eslint "src/**" --fix
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
uses: EndBug/add-and-commit@v2
|
uses: EndBug/add-and-commit@v4
|
||||||
with:
|
with:
|
||||||
author_name: Your Name
|
author_name: Your Name
|
||||||
author_email: mail@example.com
|
author_email: mail@example.com
|
||||||
message: "Your commit message"
|
message: "Your commit message"
|
||||||
path: "."
|
add: "*.js"
|
||||||
pattern: "*.js"
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
@@ -118,11 +117,10 @@ jobs:
|
|||||||
- run: echo "123" > ./pathToRepo/file.txt
|
- run: echo "123" > ./pathToRepo/file.txt
|
||||||
|
|
||||||
# ...and then use the action as you would normally do, but providing the path to the repo
|
# ...and then use the action as you would normally do, but providing the path to the repo
|
||||||
- uses: EndBug/add-and-commit@v2
|
- uses: EndBug/add-and-commit@v4
|
||||||
with:
|
with:
|
||||||
message: "Add the very useful text file"
|
message: "Add the very useful text file"
|
||||||
path: "."
|
add: "*.txt"
|
||||||
pattern: "*.txt"
|
|
||||||
cwd: "./pathToRepo/"
|
cwd: "./pathToRepo/"
|
||||||
force: true
|
force: true
|
||||||
env:
|
env:
|
||||||
|
|||||||
10
action.yml
10
action.yml
@@ -20,16 +20,12 @@ inputs:
|
|||||||
description: The message for the commit
|
description: The message for the commit
|
||||||
required: false
|
required: false
|
||||||
default: Commit from GitHub Actions
|
default: Commit from GitHub Actions
|
||||||
path:
|
add:
|
||||||
description: The path to stage files from
|
description: Arguments for the git add command
|
||||||
required: false
|
required: false
|
||||||
default: "."
|
default: "."
|
||||||
pattern:
|
|
||||||
description: The pattern that mathces file names
|
|
||||||
required: false
|
|
||||||
default: "*.*"
|
|
||||||
remove:
|
remove:
|
||||||
description: The files to remove
|
description: Arguments for the git rm command
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "add-and-commit",
|
"name": "add-and-commit",
|
||||||
"version": "2.3.0",
|
"version": "4.0.0",
|
||||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ EOF
|
|||||||
|
|
||||||
add() {
|
add() {
|
||||||
if $INPUT_FORCE; then f=-f; else f=; fi
|
if $INPUT_FORCE; then f=-f; else f=; fi
|
||||||
find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $f $x; done
|
git add $INPUT_ADD $f
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
|||||||
Reference in New Issue
Block a user