I'm using the Github actions workflow that runs on windows-latest and I'd like to use the user home directory variable instead of using an hardcoded path C:\Users\runneradmin
. On windows this is normally available in a cmd as %USERPROFILE%
.
But using %USERPROFILE%
fails in the Github actions as the syntax seems unsupported.
Also tried : ${{ env.USERPROFILE }}
which was empty.
and $env:USERPROFILE
which resulted in syntax error.
Asked
Active
Viewed 2,614 times
1

Sybuser
- 735
- 10
- 27
-
My experience with using the user home location is that it is too long in some cases. I've had issues with the path being too long for the build artifacts. This is for a large project though. NOTE: OneDrive can cause build issues with Visual Studio too. OneDrive automatically backs up everything in the user's folders when active. I'd suggest keeping at the root of the C:\ drive. Like a C:\GitRepo folder. – smurphy Feb 09 '22 at 14:30
1 Answers
3
The answer is $HOME
:
steps:
- name: Echo home
run:
echo $HOME
Log:
Run echo $HOME
C:\Users\runneradmin

Sybuser
- 735
- 10
- 27