Skip to content

Commit 7126083

Browse files
committed
feat: add working dir
1 parent d9c764f commit 7126083

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ then make sure that you configure this in your `package.json` file:
4343
```
4444

4545
### Inputs
46-
| Input Parameter | Required | Description |
47-
|:----------------:|:--------:|-------------|
48-
| semantic_version | false | Specify specifying version range for semantic-release. [[Details](#semantic_version)] |
49-
| branches | false | The branches on which releases should happen.[[Details](#branches)]<br>Support for **semantic-release above v16**. |
50-
| branch | false | The branch on which releases should happen.[[Details](#branch)]<br>Only support for **semantic-release older than v16**. |
51-
| extra_plugins | false | Extra plugins for pre-install. [[Details](#extra_plugins)] |
52-
| dry_run | false | Whether to run semantic release in `dry-run` mode. [[Details](#dry_run)] |
53-
| extends | false | Use a sharable configuration [[Details](#extends)] |
46+
| Input Parameter | Required | Description |
47+
|:-----------------:|:--------:|-------------|
48+
| semantic_version | false | Specify specifying version range for semantic-release. [[Details](#semantic_version)] |
49+
| branches | false | The branches on which releases should happen.[[Details](#branches)]<br>Support for **semantic-release above v16**. |
50+
| branch | false | The branch on which releases should happen.[[Details](#branch)]<br>Only support for **semantic-release older than v16**. |
51+
| extra_plugins | false | Extra plugins for pre-install. [[Details](#extra_plugins)] |
52+
| dry_run | false | Whether to run semantic release in `dry-run` mode. [[Details](#dry_run)] |
53+
| extends | false | Use a sharable configuration [[Details](#extends)] |
54+
| working_directory | false | Use another working directory for semantic release [[Details](#working_directory)] |
5455

5556
#### semantic_version
5657
> {Optional Input Parameter} Specify specifying version range for semantic-release.<br>If no version range is specified, latest version will be used by default.
@@ -206,6 +207,23 @@ steps:
206207
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
207208
```
208209

210+
#### working_directory
211+
This action run semantic release in the github provided workspace by default. You can override it by setting another working directory.
212+
213+
```yaml
214+
steps:
215+
- name: Checkout
216+
uses: actions/checkout@v2
217+
- name: Semantic Release
218+
uses: cycjimmy/semantic-release-action@v2
219+
with:
220+
# You can select another working directory like a subdirectory for example.
221+
working_directory: ./code
222+
env:
223+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
225+
```
226+
209227
### Outputs
210228
| Output Parameter | Description |
211229
|:-------------------------:|---|

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
extends:
2424
required: false
2525
description: 'One or several sharable configurations, https://semantic-release.gitbook.io/semantic-release/usage/configuration#extends'
26+
working_directory:
27+
required: false
28+
description: 'Specify another working directory for semantic release. Default one is provided by github.'
2629
outputs:
2730
new_release_published:
2831
description: 'Whether a new release was published'

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const inputs = require('./inputs.json');
1616
* @returns {Promise<void>}
1717
*/
1818
const release = async () => {
19+
if (core.getInput(inputs.working_directory)) {
20+
process.chdir(core.getInput(inputs.working_directory));
21+
}
1922
await setUpJob();
2023
await installSpecifyingVersionSemantic();
2124
await preInstall(core.getInput(inputs.extra_plugins));

src/inputs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"branch": "branch",
55
"extra_plugins": "extra_plugins",
66
"dry_run": "dry_run",
7-
"extends": "extends"
7+
"extends": "extends",
8+
"working_directory": "working_directory"
89
}

0 commit comments

Comments
 (0)