Skip to content

Commit

Permalink
Support multiple exclude paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
tfaris committed Dec 16, 2020
1 parent 33a2ecc commit 5df20b0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ steps
subdomain: 'mycompany'
```
Exclude multiple paths
```yaml
steps
- uses: nichevision/sharefile-upload-artifact@v1
with:
path: |
build/*.dll
build/*.config
exclude: |
*.pdb
*.xml
destination: releases/
client-id: ${{ secrets.SHAREFILE_CLIENT_ID }}
client-secret: ${{ secrets.SHAREFILE_CLIENT_SECRET }}
username: ${{ secrets.SHAREFILE_USERNAME }}
password: ${{ secrets.SHAREFILE_PASSWORD }}
subdomain: 'mycompany'
```
## Outputs
### `share-url`
Expand Down
19 changes: 15 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5331,6 +5331,13 @@ function processPath(patterns)
return result;
}

function formatAsPowershellList(stringArg)
{
var asList = processPath(stringArg);
var quoted = asList.map(x => `"${x}"`);
return "@(" + quoted.join(';') + ")";
}

async function run(config)
{
core.setSecret(config.client_id);
Expand All @@ -5343,9 +5350,12 @@ async function run(config)
.join(__dirname, '..', 'Upload-Sharefile.ps1')
.replace(/'/g, "''");

const filesToUpload = processPath(config.path);
const formattedFiles = filesToUpload.map(x => `"${x}"`);
const filesToUploadPwshList = "@(" + formattedFiles.join(';') + ")";
const filesToUploadPwshList = formatAsPowershellList(config.path);
const filesToExcludePwshList = formatAsPowershellList(config.exclude || "");

if (config.application_control_plane === "") {
config.application_control_plane = "sharefile.com";
}

let command = `& '${escapedScript}'\
-ClientID '${config.client_id}'\
Expand All @@ -5357,7 +5367,8 @@ async function run(config)
-ShareParentFolderLink\
-DestinationDirectory '${config.destination}'\
-Files ${filesToUploadPwshList}\
-Exclude '${config.exclude}'`;
-Exclude ${filesToExcludePwshList}\
-ErrorAction Stop`;

let output = '';

Expand Down
14 changes: 10 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ function processPath(patterns)
return result;
}

function formatAsPowershellList(stringArg)
{
var asList = processPath(stringArg);
var quoted = asList.map(x => `"${x}"`);
return "@(" + quoted.join(';') + ")";
}

async function run(config)
{
core.setSecret(config.client_id);
Expand All @@ -42,9 +49,8 @@ async function run(config)
.join(__dirname, '..', 'Upload-Sharefile.ps1')
.replace(/'/g, "''");

const filesToUpload = processPath(config.path);
const formattedFiles = filesToUpload.map(x => `"${x}"`);
const filesToUploadPwshList = "@(" + formattedFiles.join(';') + ")";
const filesToUploadPwshList = formatAsPowershellList(config.path);
const filesToExcludePwshList = formatAsPowershellList(config.exclude || "");

if (config.application_control_plane === "") {
config.application_control_plane = "sharefile.com";
Expand All @@ -60,7 +66,7 @@ async function run(config)
-ShareParentFolderLink\
-DestinationDirectory '${config.destination}'\
-Files ${filesToUploadPwshList}\
-Exclude '${config.exclude}'\
-Exclude ${filesToExcludePwshList}\
-ErrorAction Stop`;

let output = '';
Expand Down

0 comments on commit 5df20b0

Please sign in to comment.