Create GitHub actions that use powershell scripts

纵然是瞬间 提交于 2019-12-23 09:47:54

问题


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'

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?


回答1:


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"]

Update:

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 won't run in most Windows environment and you'd have to use Windows Server 2019 as your base environment.



来源:https://stackoverflow.com/questions/59184288/create-github-actions-that-use-powershell-scripts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!