Navigation Menu

Skip to content

How to use system environment variable in cache actions path? #27163

Answered by Yanjingzhu
evandrocoan asked this question in Actions
Discussion options

You must be logged in to vote

Hi @evandrocoan , 

In default, system environment variable is not included in env context, you could use set-env command to set the value of system ProgramFiles to an job env. And then you it with  ${{ env.ProgramFilesPath }}  syntax. 

Please see my example:

name: CI

on:
push:
paths:
- '**/main.yml'

jobs:
run_tests:
runs-on: windows-latest
steps:
# env context is empty at the beginning
- name: Dump env context
env:
ENV_CONTEXT: ${{ toJson(env) }}
run: write-host "$env:ENV_CONTEXT1"
# set system ProgramFiles value to env ProgramFilesPath
- name: set env ProgramFiles
shell: cmd
run: |
echo %programfiles%
echo ::set-env name=ProgramFilesPath::%programfiles%
# check env context again, now inc…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
1 reply
@jharris-tc
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants