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
@@ -27,6 +28,7 @@ Add a step like this to your workflow:
27
28
28
29
- `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
29
30
- `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
31
+
- `cwd` : the working directory in which your repository is located, defaults to `.`
30
32
- `message` : the message for the commit
31
33
- `path` : the path(s) to stage files from
32
34
- `pattern` : the pattern that matches file names
@@ -70,7 +72,7 @@ jobs:
70
72
runs-on: ubuntu-latest
71
73
steps:
72
74
- name: Checkout repo
73
-
uses: actions/checkout@v1
75
+
uses: actions/checkout@v2
74
76
75
77
- name: Set up Node.js
76
78
uses: actions/setup-node@v1
@@ -95,6 +97,38 @@ jobs:
95
97
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96
98
```
97
99
100
+
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.
101
+
102
+
```yaml
103
+
name: Use a different repository directory
104
+
on: push
105
+
106
+
jobs:
107
+
run:
108
+
name: Add a text file
109
+
runs-on: ubuntu-latest
110
+
111
+
steps:
112
+
# If you need to, you can checkout your repo to a different location
113
+
- uses: actions/checkout@v2
114
+
with:
115
+
path: "./pathToRepo/"
116
+
117
+
# You can make whatever type of change to the repo...
118
+
- run: echo "123" > ./pathToRepo/file.txt
119
+
120
+
# ...and then use the action as you would normally do, but providing the path to the repo
121
+
- uses: EndBug/add-and-commit@v2
122
+
with:
123
+
message: "Add the very useful text file"
124
+
path: "."
125
+
pattern: "*.txt"
126
+
cwd: "./pathToRepo/"
127
+
force: true
128
+
env:
129
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130
+
```
131
+
98
132
## License
99
133
100
134
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
0 commit comments