Add cwd option (#15)
* Add cwd option * Commit dist files * Debugging * Remove modules * Update docs * Remove debugging command * Minor formatting change
This commit is contained in:
36
README.md
36
README.md
@@ -15,6 +15,7 @@ Add a step like this to your workflow:
|
|||||||
with: # See more info about inputs below
|
with: # See more info about inputs below
|
||||||
author_name: Your Name
|
author_name: Your Name
|
||||||
author_email: mail@example.com
|
author_email: mail@example.com
|
||||||
|
cwd: "."
|
||||||
message: "Your commit message"
|
message: "Your commit message"
|
||||||
path: "."
|
path: "."
|
||||||
pattern: "*.js"
|
pattern: "*.js"
|
||||||
@@ -27,6 +28,7 @@ Add a step like this to your workflow:
|
|||||||
|
|
||||||
- `author_name` : the name of the user that will be displayed as the author of the commit, defaults to the author of the commit that triggered the run
|
- `author_name` : the name of the user that will be displayed as the author of the commit, defaults to the author of the commit that triggered the run
|
||||||
- `author_email` : the email of the user that will be displayed as the author of the commit, defaults to the author of the commit that triggered the run
|
- `author_email` : the email of the user that will be displayed as the author of the commit, defaults to the author of the commit that triggered the run
|
||||||
|
- `cwd` : the working directory in which your repository is located, defaults to `.`
|
||||||
- `message` : the message for the commit
|
- `message` : the message for the commit
|
||||||
- `path` : the path(s) to stage files from
|
- `path` : the path(s) to stage files from
|
||||||
- `pattern` : the pattern that matches file names
|
- `pattern` : the pattern that matches file names
|
||||||
@@ -70,7 +72,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@@ -95,6 +97,38 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you need to run the action on a repository that is not located in [`$GITHUB_WORKSPACE`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables), you can use the `cwd` option: the action uses a `cd` normal command, so the path should follow bash standards.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Use a different repository directory
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
name: Add a text file
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# If you need to, you can checkout your repo to a different location
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: "./pathToRepo/"
|
||||||
|
|
||||||
|
# You can make whatever type of change to the repo...
|
||||||
|
- run: echo "123" > ./pathToRepo/file.txt
|
||||||
|
|
||||||
|
# ...and then use the action as you would normally do, but providing the path to the repo
|
||||||
|
- uses: EndBug/add-and-commit@v2
|
||||||
|
with:
|
||||||
|
message: "Add the very useful text file"
|
||||||
|
path: "."
|
||||||
|
pattern: "*.txt"
|
||||||
|
cwd: "./pathToRepo/"
|
||||||
|
force: true
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ inputs:
|
|||||||
author_email:
|
author_email:
|
||||||
description: The email of the user that will be displayed as the author of the commit
|
description: The email of the user that will be displayed as the author of the commit
|
||||||
required: false
|
required: false
|
||||||
|
cwd:
|
||||||
|
description: The directory where your repository is located. You should use actions/checkout first to set it up
|
||||||
|
required: false
|
||||||
|
default: "."
|
||||||
force:
|
force:
|
||||||
description: Whether to use the force option on git add, in order to bypass eventual gitignores
|
description: Whether to use the force option on git add, in order to bypass eventual gitignores
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
cd $INPUT_CWD
|
||||||
|
echo "Running in $PWD."
|
||||||
|
|
||||||
# Set up .netrc file with GitHub credentials
|
# Set up .netrc file with GitHub credentials
|
||||||
git_setup() {
|
git_setup() {
|
||||||
cat <<- EOF > $HOME/.netrc
|
cat <<- EOF > $HOME/.netrc
|
||||||
|
|||||||
Reference in New Issue
Block a user