Reputation: 1534
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\PowerShell\7\pwsh.EXE -command ". '{0}'"
env:
runTests: true
uploadArtifacts: false
**Echo uploadArtifacts **
Run echo false
echo false
shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
env:
runTests: true
uploadArtifacts: false
false
Upvotes: 0
Views: 2776
Reputation: 1212
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.
Upvotes: 1