Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass scripts arguments #20

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ steps:
cake-bootstrap: true
```

### `script-arguments`

If you need pass same additional [argument](https://cakebuild.net/docs/writing-builds/args-and-environment-vars) value to CakeBuild, you can use `script-arguments`.
jwickowski marked this conversation as resolved.
Show resolved Hide resolved

When you add an Argument: eg.
`var assemblyVersion = Argument<string>("versionTag", "refs/tag/v0.0.0.0");`
then your step can look like that:

```yml
steps:
- name: Update-Assembly-Version
uses: jwickowski/cake-action@v0.0.2
jwickowski marked this conversation as resolved.
Show resolved Hide resolved
with:
target: "Update-Assembly-Version"
script-arguments: --versionTag=${{ github.ref }}
jwickowski marked this conversation as resolved.
Show resolved Hide resolved
```

## Cross-platform

Since the [Cake Tool](https://www.nuget.org/packages/Cake.Tool/) is built on .NET Core, the Cake action will run on any of the [virtual environments](https://help.github.com/en/github/automating-your-workflow-with-github-actions/software-in-virtual-environments-for-github-actions) supported by GitHub Actions, namely Linux, Windows and macOS.
Expand Down
29 changes: 29 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ describe('When running the action with the target input argument', () => {
});
});

describe('When running the action with the script-arguments input argument', () => {
const fakeGetInput = core.getInput as jest.MockedFunction<typeof core.getInput>;
const fakeRunScript = cake.runScript as jest.MockedFunction<typeof cake.runScript>;

test('it should run script with the specified arguments', async () => {
when(fakeGetInput).calledWith('script-arguments').mockReturnValue('--assemblyVersion=1.0.1');

await run();
expect(fakeRunScript.mock.calls[0][4]).toMatchObject(
new CakeArgument('assemblyVersion', '1.0.1'));
});
});

describe('When running the action with multiple script-arguments input argument', () => {
const fakeGetInput = core.getInput as jest.MockedFunction<typeof core.getInput>;
const fakeRunScript = cake.runScript as jest.MockedFunction<typeof cake.runScript>;

test('it should run script with the specified arguments', async () => {
when(fakeGetInput).calledWith('script-arguments').mockReturnValue('--assemblyVersion=1.0.1 --secondArg="Second value"');

await run();
expect(fakeRunScript.mock.calls[0][4]).toMatchObject(
new CakeArgument('assemblyVersion', '1.0.1'));

expect(fakeRunScript.mock.calls[0][5]).toMatchObject(
new CakeArgument('secondArg', 'Second value'));
});
});

jwickowski marked this conversation as resolved.
Show resolved Hide resolved
describe('When running the action with the verbosity input argument', () => {
const fakeGetInput = core.getInput as jest.MockedFunction<typeof core.getInput>;
const fakeRunScript = cake.runScript as jest.MockedFunction<typeof cake.runScript>;
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
description: 'Flag for if Cake modules should be installed/bootstrapped.'
required: false
default: 'false'
script-arguments:
description: 'The place to pass script arguments that will be passes to runner.'
required: false
default: ''
runs:
using: 'node12'
main: 'dist/index.js'