5

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?

6
  • 1
    I just posted an answer to your question here: stackoverflow.com/questions/59184730/… Commented Dec 4, 2019 at 22:30
  • 2
    I just skimmed the docs and my understanding is, that main is expected to be JavaScript because you say it should be executed via Node, right? So in order to be able to use a Powershell script there you'd need to say so in the using field. So, using: 'pshell.exe' or something akin to that. Commented Dec 5, 2019 at 10:59
  • 1
    @raiph 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. github.com/kaypeter87/GitHubActions-PSTest/commit/… Commented Dec 19, 2019 at 23:03
  • 2
    Thank you @PeterKay. So perhaps you could edit your answer to make it clear that there are only those two options, namely running JS or docker, and the latter won't run in most Windows environments, and thus JJ's follow up question and your answer are the only way forward for someone with JJ's scenario. Then perhaps JJ will accept your answer below to make it clear that it is as acceptable for this question as your other answer is to JJ's follow up question. (Alternatively, you can do nothing because anyone reading this will presumably now get the picture.) Either way, thanks for replying. :) Commented Dec 19, 2019 at 23:36
  • 1
    @raiph thanks for the great moderating! I went ahead and updated the answer below for clarity. Commented Dec 20, 2019 at 19:54

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Docker environments don't run in Windows.
Technically, you can with process isolation. Though, it is only possible in Windows 10/Server 2019.
But is Windows Server 2019 available as base environment in GitHub Actions?
It is, it can be assigned using windows-latest, you can also look at available software/OS here: help.github.com/en/actions/… and here: help.github.com/en/actions/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.