Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Pilot Lvl 1
Message 1 of 4

Windows - run a PowerShell script

Solved! Go to Solution.

Trying to move CI from AppVeyor to Actions, which used PowerShell files for build and test.

 

Reviewed https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrunshell, which I found without examples.  So, stupid question - how to run a ps1 file in an Actions step?

 

 

3 Replies
Highlighted
Copilot Lvl 3
Message 2 of 4

Re: Windows - run a PowerShell script

I was also trying to figure out how to use the shell option to run a powershell script. The doc shows the following definition:

 

 

jobs.<job_id>.steps.run.shell

 

 

So I tried to make a sub-property of run (which I don't think is valid yml, but the editor doesn't do any validation so it's hard to tell):

 

name: CI

on:
  push:
    branches:
    - master

jobs:
  build:

    runs-on: windows-2019

    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: .\MyScripts\install.ps1
        shell: powershell

 

Which errored with:

 

yaml: line 17: mapping values are not allowed in this context

I gave up and just used powershell from the cmd command instead of trying to change the shell:

 

name: CI

on:
  push:
    branches:
    - master

jobs:
  build:

    runs-on: windows-2019
    
    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: powershell .\MyScripts\install.ps1

 

Hopefully some examples can be added to that page to show how to actually use the shell parameter

Highlighted
Ground Controller Lvl 1
Message 3 of 4

Re: Windows - run a PowerShell script

Try:

 

name: CI

on:
  push:
    branches:
    - master

jobs:
  build:

    runs-on: windows-2019

    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: .\MyScripts\install.ps1
      shell: powershell

 

Its working for me - https://github.com/damccorm/actions-playground/pull/9 - I think this is just a docs issue

 

cc @rachmari 

Solution
GitHub Staff
Message 4 of 4

Re: Windows - run a PowerShell script

Hey there, thanks for pointing this out. It was indeed a documentation bug. We've fixed the documentation and added examples for using different shells! Let me know if there is still some clarification we can make in the documentation. 

You'll find the updated documentation here:
https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsrun