创建使用Powershell脚本的GitHub操作 [英] Create GitHub actions that use powershell scripts
问题描述
我想创建一个GitHub操作,该操作在Windows中设置环境,并运行一些Powershell命令.尽管可以很容易地做到这一点,但是似乎没有一种方法可以为此创建完整的GitHub动作.如果我使用这个:
I'd like to create a GitHub action that sets up an environment in Windows, running a few Powershell commands. Despite this can be done easily as a step, there does not seem to be a way to create a complete GitHub action for that. If I use this:
name: 'Rakudo Star fix for windows'
description: 'Updates zef for RakudoStar'
author: 'JJ'
runs:
using: 'node12'
main: 'upgrade.ps1'
除了JS脚本,甚至没有声明环境的方法,似乎没有其他方法可以运行.我知道在工作步骤中还有待日后处理,但无论如何看起来还是很hack.我在这里想念什么吗?
There does not seem a way to run anything other than a JS script, or even to declare the environment. I understand that's left for later, during the job steps, but anyway it looks like a hack. Is there anything I'm missing here?
推荐答案
您还可以使用.ps1脚本的入口点直接运行docker
You could also run docker directly with an entrypoint for the .ps1 script
FROM ubuntu:18.04
LABEL "com.github.actions.name"="test"
LABEL "com.github.actions.description"="test."
RUN apt-get update \
&& apt-get install wget -y \
&& wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& apt-get update \
&& apt-get install -y powershell
ADD test.ps1 /test.ps1
ENTRYPOINT ["pwsh", "/test.ps1"]
更新:
using
字段是用于执行main
中指定的代码的应用程序.但是Github Actions仅支持使用node12
和docker
.从此 GHActions 我只是举个例子清酒.
The using
field is the application to use to execute the code specified in main
. But Github Actions only support using node12
and docker
. As seen from this GHActions I just ran for example's sake.
Docker无法在大多数Windows环境中运行,并且您必须使用Windows Server 2019作为基本环境.
Docker won't run in most Windows environment and you'd have to use Windows Server 2019 as your base environment.
这篇关于创建使用Powershell脚本的GitHub操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!