PowerShell environment variables and filenames in Actions

I have an action that needs to generate a UWP package. Things worked fine when my commands were plain and didn’t use any environment variables. I.e.:

      - run: |
          makeappx pack /d myproject /p myproject.appx

Now, in an effort to make this action more generic, I’ve done:

      - run: echo ::set-env name=REPOSITORY_NAME::$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")
        shell: bash


makeappx pack /d ${env:REPOSITORY_NAME} /p ${env:REPOSITORY_NAME}.appx

When doing that, I get an error about the “/p” option not being recognized. I suspect a command line parsing bug where perhaps a missing parameter reports as an unknown option, so I do:

move package.appx ${env:REPOSITORY_NAME}.appx

after generating package.appx. As suspected, move complains that the destination is null.

Interestingly, I have:

          makeappx unpack /p uwp\${env:REPOSITORY_NAME}.appx /d ${env:REPOSITORY_NAME}

earlier in my action, and it works just fine. So there’s something with my use of ${env:REPOSITORY_NAME}.appx later that doesn’t work. Also, $REPOSITORY_NAME works fine on my Linux jobs, so I know that it is getting set correctly.

What am I doing wrong here? This is probably more of a generic PowerShell issue, but it seems like I’m using environment variables correctly, and I can’t find the right Google keywords to fix this.



I’m not sure what exactly is causing your issue, but can you try this syntax instead and see if it works:

move package.appx ${{ env.REPOSITORY_NAME  }}.appx

This lets GitHub interpolate the env for you

1 Like

Doh, didn’t even think about that. Yeah, that seems to have fixed it.