英文:
Is there a way i can specify the github action workflow to use powershell 7 instead of default powershell 5?
问题
我有一个工作流程,将在本地运行器上运行一个PowerShell脚本,我已经尝试与ChatGPT争论,但它无法给我一个正确的答案,告诉我如何指定我要使用PowerShell 7。这是因为PowerShell脚本中使用的一个模块不支持较早版本的PowerShell。
这是工作流YAML文件目前的样子:
name: PowerShell脚本
on:
push:
branches:
- master
jobs:
myJob:
name: PS - 更新列表
runs-on: self-hosted
steps:
- name: 检出存储库代码
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: 运行PowerShell脚本
shell: pwsh7
env:
Creds: ${{ secrets.Creds }}
run: |
./Something.ps1
错误:
英文:
I have a workflow that is going to run a powershell script on a local runner, i have tried arguing with chatgpt but it cannot give me a correct answer to how i can spesify that i want to use powershell 7. This is needed because one of the modules used in the powershell script is not supported in earlier versions of powershell.
This is what the workflow yaml file is currently looking like:
name: Powershell script
on:
push:
branches:
- master
jobs:
myJob:
name: PS - Update list
runs-on: self-hosted
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Run PowerShell script
shell: pwsh7
env:
Creds: ${{ secrets.Creds }}
run: |
./Something.ps1
Error:
答案1
得分: 1
感谢大家的评论!
正如Mathias在评论中写道,我必须使用'shell: pwsh',这将始终将PowerShell 7作为默认选项。如果您要使用早期版本,如PowerShell 5,则需要更改为其他选项,我相信。
英文:
Thanks for everyones comments!
As Mathias wrote in a comment i had to use 'shell: pwsh' instead this always uses powershell 7 as default. If you're gonna use an earlier version like powershell 5 then you need to change this to something else i belive.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论