Skip to content

Commit 68cece3

Browse files
initial commit
1 parent 1823208 commit 68cece3

27 files changed

Lines changed: 964 additions & 0 deletions

.github/workflows/test.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths-ignore:
7+
- '**.md'
8+
- '**.MD'
9+
pull_request:
10+
branches: [ main ]
11+
types: [opened, synchronize, reopened]
12+
paths-ignore:
13+
- '**.md'
14+
- '**.MD'
15+
16+
workflow_dispatch:
17+
18+
jobs:
19+
test:
20+
runs-on: [self-hosted, windows, x64, philips, servercore-20H2]
21+
name: Test
22+
env:
23+
TEST1: Test1
24+
TEST2: Test2
25+
TEST3: ${{ secrets.TEST_SECRET }}
26+
strategy:
27+
matrix:
28+
docker_container: ["mcr.microsoft.com/windows/servercore:20H2"]
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
fetch-depth: 0
35+
- name: Test_Run_Default
36+
uses: ./
37+
with:
38+
image: ${{ matrix.docker_container }}
39+
entrypoint: powershell.exe
40+
env_names: GITHUB_WORKSPACE
41+
run: >-
42+
${{ github.workspace }}\test\run_test.ps1 -testPath "${{ github.workspace }}\test\run_default.Tests.ps1";
43+
44+
- name: Test_ExtraArgs
45+
uses: ./
46+
with:
47+
image: ${{ matrix.docker_container }}
48+
workspace_path: ${{ github.workspace }}
49+
extra_args: --entrypoint cmd.exe
50+
run: >-
51+
echo "Hello world";
52+
exit %ERRORLEVEL%;
53+
- name: Test_Environment
54+
uses: ./
55+
with:
56+
image: ${{ matrix.docker_container }}
57+
entrypoint: powershell.exe
58+
env_names: TEST1, TEST2, TEST3
59+
run: >-
60+
${{ github.workspace }}\test\run_test.ps1 -testPath "${{ github.workspace }}\test\environment.Tests.ps1";
61+
62+
- name: Test_WorkPath
63+
uses: ./
64+
with:
65+
image: ${{ matrix.docker_container }}
66+
work_path: 'c:\temp'
67+
entrypoint: powershell.exe
68+
memory: 3GB
69+
run: >-
70+
${{ github.workspace }}\test\run_test.ps1 -testPath "${{ github.workspace }}\test\work_path.Tests.ps1";
71+
72+
- name: Test_MappingPath
73+
uses: ./
74+
with:
75+
image: ${{ matrix.docker_container }}
76+
mapping_path: 'c:\mapping'
77+
work_path: 'c:\temp'
78+
entrypoint: powershell.exe
79+
memory: 3GB
80+
run: >-
81+
c:\mapping\test\run_test.ps1 -testPath "c:\mapping\test\mapping_path.Tests.ps1";
82+
83+
- name: Test_WorkSpacePath
84+
uses: ./
85+
with:
86+
image: ${{ matrix.docker_container }}
87+
workspace_path: ${{ github.workspace }}/test
88+
entrypoint: powershell.exe
89+
memory: 3GB
90+
env_names: GITHUB_WORKSPACE
91+
run: >-
92+
${{ github.workspace }}\test\run_test.ps1 -testPath "${{ github.workspace }}\test\workspace_path.Tests.ps1";
93+
94+
validate:
95+
runs-on: [self-hosted, linux, X64, philips]
96+
name: Validate
97+
container: mcr.microsoft.com/powershell:latest
98+
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v3
102+
with:
103+
fetch-depth: 0
104+
- name: Install
105+
shell: pwsh
106+
run: >-
107+
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted;
108+
Install-Module -Name Pester -Force -SkipPublisherCheck;
109+
Update-Module -Name Pester -Force;
110+
Install-Module -Name PSScriptAnalyzer -Force;
111+
- name: Linter src
112+
shell: pwsh
113+
run: >-
114+
Invoke-ScriptAnalyzer -Path src -EnableExit;
115+
- name: Linter test
116+
shell: pwsh
117+
run: >-
118+
Invoke-ScriptAnalyzer -Path test -EnableExit;
119+
- name: Test-Action-Scripts
120+
shell: pwsh
121+
run: >-
122+
cd src;
123+
$config=New-PesterConfiguration;
124+
$config.Run.Exit=$true;
125+
Invoke-Pester -Configuration $config;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Update README
2+
on:
3+
push:
4+
branches: [ main ]
5+
6+
jobs:
7+
update-readme:
8+
9+
runs-on: [self-hosted, linux, X64, philips]
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Update README
15+
uses: npalm/action-docs-action@v1.2.0
16+
with:
17+
readme: ./README.md
18+
actionFile: ./action.yml
19+
tocLevel: 2
20+
lineBreaks: LF
21+
22+
- name: commit and push
23+
uses: stefanzweifel/git-auto-commit-action@v4.15.0
24+
with:
25+
commit_message: "Auto-update README.md"
26+
branch: "update-readme"
27+
push_options: '--force'
28+
29+
- name: Create pull request
30+
uses: devops-infra/action-pull-request@master
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
source_branch: update-readme
34+
target_branch: main
35+
label: automated
36+
title: Update README.md
37+
body: "Automatically updated contents of README.md based on an updated action.yml file"

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* edward.van.de.vorst@philips.com

CONTRIBUTING.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Contributing to run-windows-docker-container-action
2+
3+
We'd love for you to contribute to our source code and to make the Forest even better than it is today! Here are the guidelines we'd like you to follow:
4+
5+
- [Question or Problem?](#question)
6+
- [Issues and Bugs](#issue)
7+
- [Feature Requests](#feature)
8+
- [Submission Guidelines](#submit)
9+
- [Further Info](#info)
10+
11+
## <a name="question"></a> Got a Question or Problem?
12+
13+
If you have questions about how to use the Forest, please direct these to the [maintainers](CODEOWNERS)
14+
15+
## <a name="issue"></a> Found an Issue?
16+
17+
If you find a bug in the source code or a mistake in the documentation, you can help us by submitting an issue to our [GitHub Repository][github]. Even better you can submit a Pull Request with a fix.
18+
19+
**Please see the [Submission Guidelines](#submit) below.**
20+
21+
## <a name="feature"></a> Want a Feature?
22+
23+
You can request a new feature by submitting an issue to our [GitHub Repository][github]. If you would like to implement a new feature, it
24+
can be crafted and submitted to the [GitHub Repository][github] as a Pull Request.
25+
26+
## <a name="submit"></a> Submission Guidelines
27+
28+
### Submitting an Issue
29+
Before you submit your issue search the archive, maybe your question was already answered.
30+
31+
If your issue appears to be a bug, and hasn't been reported, open a new issue. Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues. Providing the following information will increase the chances of your issue being dealt with quickly:
32+
33+
* **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
34+
* **Motivation for or Use Case** - explain why this is a bug for you
35+
* **Version(s)** - is it a regression?
36+
* **Reproduce the Error** - try to describe how to reproduce the error
37+
* **Related Issues** - has a similar issue been reported before?
38+
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
39+
causing the problem (line of code or commit)
40+
41+
**If you get help, help others. Good karma rulez!**
42+
43+
### Submitting a Merge Request
44+
Before you submit your merge request consider the following guidelines:
45+
46+
* Make your changes in a new git branch:
47+
48+
```shell
49+
git checkout -b my-fix-branch develop
50+
```
51+
52+
* Create your patch, **including appropriate test cases**.
53+
* Run the test suite and ensure that all tests pass.
54+
* Add a line in the CHANGELOG.md under Unreleased. This will be used form generating the release notes.
55+
* Commit your changes using a descriptive commit message.
56+
57+
```shell
58+
git commit -a
59+
```
60+
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
61+
62+
* Build your changes locally to ensure all the tests pass:
63+
* Push your branch to GitHub:
64+
65+
```shell
66+
git push origin my-fix-branch
67+
```
68+
69+
In GitHub, send a pull request to original main branch.
70+
If we suggest changes, then:
71+
72+
* Make the required updates.
73+
* Re-run the test suite to ensure tests are still passing.
74+
* Commit your changes to your branch (e.g. `my-fix-branch`).
75+
* Push the changes to your GitHub repository (this will update your Pull Request).
76+
77+
If the PR gets too outdated we may ask you to rebase and force push to update the PR:
78+
79+
```shell
80+
git rebase main -i
81+
git push origin my-fix-branch -f
82+
```
83+
84+
_WARNING: Squashing or reverting commits and force-pushing thereafter may remove GitHub comments on code that were previously made by you or others in your commits. Avoid any form of rebasing unless necessary._
85+
86+
That's it! Thank you for your contribution!
87+
88+
#### After your merge request is merged
89+
90+
After your pull request is merged, you can safely delete your branch and pull the changes
91+
from the main (upstream) repository:
92+
93+
* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
94+
95+
```shell
96+
git push origin --delete my-fix-branch
97+
```
98+
99+
* Check out the main branch:
100+
101+
```shell
102+
git checkout main -f
103+
```
104+
105+
* Delete the local branch:
106+
107+
```shell
108+
git branch -D my-fix-branch
109+
```
110+
111+
* Update your main with the latest upstream version:
112+
113+
```shell
114+
git pull --ff upstream main
115+
```
116+
117+
## <a name="info"></a> Info
118+
119+
For more info, please reach out to the [maintainers](CODEOWNERS)
120+
121+
[contribute]: CONTRIBUTING.md
122+
[github]: https://github.com/philips-software/run-windows-docker-container-action/issues

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
# Action for running commands in a windows docker
3+
4+
## State
5+
6+
[![Test](https://github.com/philips-software/run-windows-docker-container-action/actions/workflows/test.yml/badge.svg)](https://github.com/philips-software/run-windows-docker-container-action/actions/workflows/test.yml)
7+
8+
## Description
9+
10+
Composite action for running commands in windows docker containers.
11+
12+
## Usage
13+
14+
Very simple hello world example:
15+
16+
```
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
- name: Test_Run
23+
uses: philips-software/run-windows-docker-container-action@<version>
24+
with:
25+
image: mcr.microsoft.com/windows/servercore:20H2
26+
entrypoint: powershell.exe
27+
run: >-
28+
echo "Hello world";
29+
./run-test-script.ps1;
30+
```
31+
32+
On default, the github workspace directory is mapped to the docker volume path
33+
and work path.
34+
35+
<!-- action-docs-inputs -->
36+
## Inputs
37+
38+
| parameter | description | required | default |
39+
| - | - | - | - |
40+
| image | Docker image. | `true` | |
41+
| run | Command to execute. | `true` | |
42+
| workspace_path | Workspace path. Default is root workspace path. | `false` | |
43+
| mapping_path | Mapping path, i.e. path to where the workspace path is mapped in the docker container. Defaults to workspace_path. | `false` | |
44+
| work_path | Work path, i.e. path where the command in the docker container is executed. Defaults to workspace_path. | `false` | |
45+
| memory | Memory limit. See docker documentation on --memory. | `false` | 4GB |
46+
| entrypoint | Overrides the default ENTRYPOINT in docker image. | `false` | |
47+
| env_names | Environment variable names passed to docker image as comma separated list, for example: NAME1, NAME2, NAME3 | `false` | |
48+
| extra_args | Extra arguments for docker run command. | `false` | |
49+
50+
<!-- action-docs-inputs -->
51+
52+
53+
<!-- action-docs-runs -->
54+
## Runs
55+
56+
This action is an `composite` action.
57+
58+
59+
<!-- action-docs-runs -->
60+
61+
## Contributing
62+
63+
Please refer to our [Contributing](CONTRIBUTING.md) guide when you want to contribute to this project.
64+
65+
## License
66+
67+
Run-Windows-Docker-Container is licenced under the [MIT](https://choosealicense.com/licenses/mit/) license. See [LICENSE file](LICENSE).

0 commit comments

Comments
 (0)