Skip to content

Commit cdb1b56

Browse files
committed
Enclosed the docker run command in an expandable Here-String to accomodate multiline commands for entry points that support it.
Updated the documentation accordingly. Replaced 'echo' with 'Write-Output' when used in Powershell context.
1 parent 945c211 commit cdb1b56

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@ Composite action for running commands in windows docker containers.
1111

1212
## Usage
1313

14-
Very simple hello world example:
14+
Simple 'Hello world' example using the default `cmd.exe` ENTRYPOINT with the `/C` option:
15+
```
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Test_Run
22+
uses: philips-software/run-windows-docker-container-action@<version>
23+
with:
24+
image: mcr.microsoft.com/windows/servercore:20H2
25+
entrypoint_args: /C
26+
run: >-
27+
echo Hello world &
28+
call run-test-script.bat;
29+
```
1530

31+
Simple 'Hello world' example overriding the default ENTRYPOINT:
1632
```
1733
steps:
1834
- name: Checkout
@@ -25,7 +41,7 @@ Very simple hello world example:
2541
image: mcr.microsoft.com/windows/servercore:20H2
2642
entrypoint: powershell.exe
2743
run: >-
28-
echo "Hello world";
44+
Write-Output "Hello world";
2945
./run-test-script.ps1;
3046
```
3147

@@ -44,25 +60,27 @@ and work path.
4460
| parameter | description | required | default |
4561
| - | - | - | - |
4662
| image | Docker image. | `true` | |
47-
| run | Command to execute. | `true` | |
63+
| run | Command to execute. Must be single line for cmd.exe entry point (use &, && or \|\| operators to aggregate multiple commands). Can be multiline for entry points that support it, like powershell.exe. | `true` | |
4864
| workspace_path | Workspace path. Default is root workspace path. | `false` | |
4965
| mapping_path | Mapping path, i.e. path to where the workspace path is mapped in the docker container. Defaults to workspace_path. | `false` | |
5066
| work_path | Work path, i.e. path where the command in the docker container is executed. Defaults to workspace_path. | `false` | |
5167
| memory | Memory limit. See docker documentation on --memory. | `false` | 4GB |
5268
| entrypoint | Overrides the default ENTRYPOINT in docker image. | `false` | |
69+
| entrypoint_args | Optional arguments for the ENTRYPOINT (default or overriden). For instance, `/S /C` for cmd.exe or `-NoLogo -NonInteractive -NoProfile` for powershell.exe. | `false` | |
5370
| env_names | Environment variable names passed to docker image as comma separated list, for example: NAME1, NAME2, NAME3 | `false` | |
5471
| extra_args | Extra arguments for docker run command. | `false` | |
5572
| pre-warm | Run a warming-up container (which might crash due to first time use failure) | `false` | true |
56-
| pre-warm-cmd | Pre warm command to run inside the container | `false` | echo "warming up!" |
73+
| pre-warm-cmd | Pre warm command to run inside the container | `false` | Write-Output "warming up!" |
5774
| registry_authentication | Authenticate against registry server | `false` | false |
5875
| registry_username | Docker registry username. | `false` | |
5976
| registry_token | Docker registry token | `false` | |
6077
| registry_repository | Docker registry repository | `false` | |
6178

6279

80+
<!-- action-docs-outputs -->
81+
## Outputs
6382

64-
<!-- action-docs-inputs -->
65-
83+
N/A
6684

6785
<!-- action-docs-runs -->
6886
## Runs

action.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
description: 'Docker image.'
1111
required: true
1212
run:
13-
description: 'Command to execute.'
13+
description: 'Command to execute. Must be single line for cmd.exe entry point (use &, && or \|\| operators to aggregate multiple commands). Can be multiline for entry points that support it, like powershell.exe.'
1414
required: true
1515
workspace_path:
1616
description: 'Workspace path. Default is root workspace path.'
@@ -30,7 +30,7 @@ inputs:
3030
required: false
3131
default: ''
3232
entrypoint_args:
33-
description: "Extra args for the ENTRYPOINT (default or overriden)."
33+
description: "Optional arguments for the ENTRYPOINT (default or overriden). For instance, `/S /C` for cmd.exe or `-NoLogo -NonInteractive -NoProfile` for powershell.exe."
3434
required: false
3535
default: ''
3636
env_names:
@@ -48,7 +48,7 @@ inputs:
4848
pre-warm-cmd:
4949
description: 'Pre warm command to run inside the container'
5050
required: false
51-
default: 'echo "warming up!"'
51+
default: 'Write-Output "warming up!"'
5252
registry_authentication:
5353
description : 'Authenticate against registry server'
5454
required : false
@@ -96,8 +96,12 @@ runs:
9696
-w ${{ steps.settings.outputs.work_path }}
9797
${{ inputs.image }}
9898
${{ inputs.entrypoint_args }}
99+
@"
100+
99101
${{ inputs.pre-warm-cmd }}
100102
103+
"@
104+
101105
exit 0
102106
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
103107
- name: Run
@@ -116,7 +120,11 @@ runs:
116120
-w ${{ steps.settings.outputs.work_path }}
117121
${{ inputs.image }}
118122
${{ inputs.entrypoint_args }}
123+
@"
124+
119125
${{ inputs.run }}
126+
127+
"@
120128
shell: powershell -NoLogo -NonInteractive -NoProfile -Command ". '{0}'"
121129
- name: docker_logout
122130
id: docker_logout

0 commit comments

Comments
 (0)