-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7991ad
Showing
9 changed files
with
1,963 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: knicknic/os-specific-run@master | ||
with: | ||
macos: echo "Hi from macos" | ||
linux: | | ||
echo "Hi from linux" | ||
echo "Hi from linux second line" | ||
windows: echo "Hi from windows" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Nick Maliwacki | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# os-specific-run | ||
|
||
A github action for running a separate command based on the os | ||
|
||
|
||
## Params | ||
|
||
### (optional) Command you wish to run | ||
| os | command value | | ||
|---------|-----------------------------------------| | ||
| macos | echo "No command specified for macos" | | ||
| linux | echo "No command specified for linux" | | ||
| windows | echo "No command specified for windows" | | ||
|
||
### (optional) Shell you wish to use | ||
| os | command value | | ||
|---------|-----------------------------------------| | ||
| macosShell | bash | | ||
| linuxShell | bash | | ||
| windowsShell | pwsh | | ||
|
||
See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell for more details | ||
|
||
## Example | ||
|
||
```yaml | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: knicknic/os-specific-run@master | ||
with: | ||
macos: echo "Hi from macos" | ||
linux: | | ||
echo "Hi from linux" | ||
echo "Hi from linux second line" | ||
windows: echo "Hi from windows" | ||
``` | ||
## Alternatives | ||
You can do what this project accomplishes with simple `if` statements in github actions. | ||
|
||
The problem is you have to figure them out, and they end up creating multiple steps one per each OS. I think a single step (rather than multiple steps in each OS that are not run) looks cleaner and is more obvious what failed. More details on if statements - https://github.community/t/what-is-the-correct-if-condition-syntax-for-checking-matrix-os-version/16221/4 | ||
|
||
## Developer instructions | ||
|
||
### Setup Environment | ||
|
||
```pwsh | ||
npm i -g @zeit/ncc | ||
npm install | ||
``` | ||
|
||
### Update project | ||
|
||
```pwsh | ||
ncc build index.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: 'OS specific run' | ||
description: 'Run a command based on the OS' | ||
inputs: | ||
linux: # id of input | ||
description: 'linux commandline' | ||
required: false | ||
default: 'echo "No command specified for linux"' | ||
macos: # id of input | ||
description: 'macos commandline' | ||
required: false | ||
default: 'echo "No command specified for macos"' | ||
windows: # id of input | ||
description: 'windows commandline' | ||
required: false | ||
default: 'echo "No command specified for windows"' | ||
linuxShell: # id of input | ||
description: 'linux commandline shell' | ||
required: false | ||
default: 'bash' | ||
macosShell: # id of input | ||
description: 'macos commandline shell' | ||
required: false | ||
default: 'bash' | ||
windowsShell: # id of input | ||
description: 'windows commandline shell' | ||
required: false | ||
default: 'pwsh' | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Oops, something went wrong.