-
Followling investigation I have to conclude that currently secrets don’t work within the windows-latest or windows-2019 frameworks. I have two workflows on the same repository. One uses ubuntu-latest and the other windows-latest. They should have the same visibility. When I replace the username and password on the code below with literal text it works. Secrets are not functional within the windows environment. If there is something I am missing please let me know. - name: Docker login echo “$DockerPassword” | docker login -u “$DockerUserName” --password-stdin index.docker.io |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Solution was to use: echo “$env:DockerPassword” | docker login -u “$env:DockerUserName” --password-stdin index.docker.io |
Beta Was this translation helpful? Give feedback.
-
Hi @naj8ry , Yeah, you are right. In windows runner, the default shell for runs is powershell. In powershell script, you need to use $env:var_name syntax to invoke envirnoment variable. There is the document for using a specific shell: https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell |
Beta Was this translation helpful? Give feedback.
-
@naj8ry , Yeah, when you want to access the environment variables in the command lines, the expression syntaxes are different on different shells. For example:
However, if the environment variables are defined by the following ways,
the environment variables will be added to the env context, then you can use the expression syntax " ${{ env.<env name> }}" to access the environment variables. This expression syntax almost can be available to all the shells. For example:
|
Beta Was this translation helpful? Give feedback.
-
That is great guys, Thank you for your help. @brightran Is is possible to add this to the documentation on environmental variables? I did read: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables having this as an appendix might save someone else some time. Thanks again, Nicholas |
Beta Was this translation helpful? Give feedback.
@naj8ry ,
Yeah, when you want to access the environment variables in the command lines, the expression syntaxes are different on different shells.
For example: