Skip to content

Commit

Permalink
Add Working Directory Input (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoSadie authored Jul 18, 2023
1 parent 05f2662 commit a626f1d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ For the `DistributionTool` to find the inputted directory path, the environment

Usage
-----
## Simple Example

### Folder Structure:
```
.github
- workflows
- your_workflow.yml
com.company.plugin_name.sdPlugin
- <your plugin files>
release
```

### Workflow Step:
```
- name: StreamDeck Distribution Tool
uses: AdamCarballo/streamdeck-distribution-tool@v1
Expand All @@ -17,6 +30,30 @@ Usage
```
This example will take the contents of the `com.company.plugin_name.sdPlugin` folder and export the plugin into the `release` directory.

## Complex Example

### Folder Structure:
```
.github
- workflows
- your_workflow.yml
plugin
- com.company.plugin_name.sdPlugin
- <your plugin files>
release
```

### Workflow Step:
```
- name: StreamDeck Distribution Tool
uses: AdamCarballo/streamdeck-distribution-tool@v1
with:
input: com.company.plugin_name.sdPlugin
output: ../release
working-directory: plugin
```
This example shows how to use the `working-directory` input when the plugin source files are not in the root of the repository. In addition, the `output` directory is set to `../release` to export the plugin into the `release` directory, to show how to use relative paths, including parent directories.

The `DistributionTool` requires both directories to exist (*it can't create directories*) and it must be run in a Windows or MacOS machine. **Linux (*`ubuntu-latest`, etc.*) is not supported**.

Inputs
Expand All @@ -28,10 +65,16 @@ Source files directory path.<br>
- **Required**: Yes

#### `output`
Exported plugin directory path.
Exported plugin directory path. Use relative paths from the directory `$GITHUB_WORKSPACE`/`working-directory`. If omitted, the action will default to outputting the plugin file in the same directory as the source folder.

- **Required**: No
- **Default**: . *(`$GITHUB_WORKSPACE`/`working-directory`)*

#### `working-directory`
Working directory path. Relative to the value of `$GITHUB_WORKSPACE`. If not set, the action will assume the `.sdPlugin` folder is in the root of the repository.

- **Required**: No
- **Default**: / *(`$GITHUB_WORKSPACE`)*
- **Default**: . *(No effect)*

Legal
------
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ inputs:
output:
description: 'Exported plugin directory path'
required: false
default: '/'
default: '.'
working-directory:
description: 'Directory .sdPlugin directory is in, relative to GITHUB_WORKSPACE'
required: false
default: '.'
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/main.sh ${{ inputs.input }} ${{ inputs.output }} ${{ runner.os }}
- run: $GITHUB_ACTION_PATH/main.sh ${{ inputs.input }} ${{ inputs.output }} ${{ runner.os }} ${{ inputs.working-directory }}
shell: bash
7 changes: 5 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
# $1 = input path
# $2 = output path
# $3 = runtime OS
# $4 = working directory

if [[ $3 == "Windows" ]]
then
$GITHUB_ACTION_PATH/DistributionTool.exe -b -i "$GITHUB_WORKSPACE\\$1" -o "$GITHUB_WORKSPACE\\$2"
cd $GITHUB_WORKSPACE\\$4
$GITHUB_ACTION_PATH/DistributionTool.exe -b -i "$1" -o "$2"
elif [[ $3 == "macOS" ]]
then
$GITHUB_ACTION_PATH/./DistributionTool -b -i "$GITHUB_WORKSPACE/$1" -o "$GITHUB_WORKSPACE/$2"
cd $GITHUB_WORKSPACE/$4
$GITHUB_ACTION_PATH/./DistributionTool -b -i "$1" -o "$2"
else
echo "StreamDeck Distribution Tool only has binaries for Windows or MacOS."
exit 1
Expand Down

0 comments on commit a626f1d

Please sign in to comment.