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

Run script file for Linux and Windows #154

Closed
Sebazzz opened this issue Sep 30, 2019 · 2 comments
Closed

Run script file for Linux and Windows #154

Sebazzz opened this issue Sep 30, 2019 · 2 comments

Comments

@Sebazzz
Copy link

Sebazzz commented Sep 30, 2019

In my repository I have a script file "build.sh" for Linux and "build.cmd" or "build.ps1" for Windows. Linux or Windows, the parameters of these files are the same.

How do I either script without duplicating my steps?

Currently I have steps like:

            - name: Build - restore nuget packages (windows-only)
              if: contains(matrix.os, 'windows')
              run: .\build.cmd --target=restore-nuget-packages --verbosity=verbose

            - name: Build - restore nuget packages (linux-only)
              if: !contains(matrix.os, 'windows')
              run: ./build.sh --target=restore-nuget-packages --verbosity=verbose

Repeating this seems very cumbersome.

Is there perhaps the possibility to set some variable to the script file? Or automatically set the extension/command used?

@Sebazzz
Copy link
Author

Sebazzz commented Sep 30, 2019

Apparently you can use/abuse the matrix for this:

        strategy:
            matrix:
                os: [windows-2019, ubuntu-16.04]
                include:
                    - os: windows-2019
                      script_name: .\build.cmd
                    - os: ubuntu-16.04
                      script_name: ./build.sh

Then in the action:

            - name: Build - restore nuget packages
              run: ${{ matrix.script_name }} --target=restore-nuget-packages --verbosity=verbose

@andymckay
Copy link
Contributor

Thank you @Sebazzz 🙇 for creating the issue in this repository, but we are trying to keep issues related to the code in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants