0

It should be possible to update the environment variable using commands like

echo "uploadArtifacts = '${{ inputs.uploadArtifacts}}'" >> $GITHUB_ENV However, it doesn't seem to be working for my example below, run: echo ${{ env.uploadArtifacts }} always evaluate to false


name: Example
on:
 workflow_dispatch:
 inputs:
 runTests:
 description: run tests
 required: true
 default: true
 type: Boolean
 uploadArtifacts:
 description: upload artifacts 
 required: true
 default: true
 type: Boolean
 push:
 branches:
 - main
 
env:
 runTests: 'true'
 uploadArtifacts: 'false'
jobs:
 Build_Job:
 runs-on: [self-hosted]
 steps:
 - name: Sets env vars for manual run
 if: ${{ inputs.uploadArtifacts}}
 run: |-
 echo "uploadArtifacts = '${{ inputs.uploadArtifacts}}'" >> $GITHUB_ENV
 echo "runTests = '${{ inputs.runTests}}'" >> $GITHUB_ENV
 - name: Echo uploadArtifacts 
 run: echo ${{ env.uploadArtifacts }}

The logs from the github actions

**Sets env vars for manual run**
Run echo "uploadArtifacts = 'true'" >> $GITHUB_ENV
 echo "uploadArtifacts = 'true'" >> $GITHUB_ENV
 echo "runTests = 'false'" >> $GITHUB_ENV
 shell: C:\Program Files\PowerShell7円\pwsh.EXE -command ". '{0}'"
 env:
 runTests: true
 uploadArtifacts: false
 
**Echo uploadArtifacts **
Run echo false
 echo false
 shell: C:\Program Files\PowerShell7円\pwsh.EXE -command ". '{0}'"
 env:
 runTests: true
 uploadArtifacts: false
 
false
asked Sep 6, 2022 at 9:33

1 Answer 1

1

It can look silly, but try removing the extra spaces inside the echo string, instead of: echo "uploadArtifacts = '${{ inputs.uploadArtifacts }}'" >> $GITHUB_ENV do echo "uploadArtifacts='${{ inputs.uploadArtifacts }}'" >> $GITHUB_ENV. I would also remove the quotes for the value, to make it true instead of 'true'. That will convert it in a real boolean, otherwise it will be treated as a string.

answered Sep 8, 2022 at 15:32
Sign up to request clarification or add additional context in comments.

1 Comment

also on windows we need to do $env:GITHUB_ENV

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.