How to set system path variable in github action workflow
Asked Answered
B

2

23

I was wondering how I can set the system path variables in the GitHub actions workflow.

export "$PATH:$ANYTHING/SOMETHING:$AA/BB/bin"
Backchat answered 1/7, 2021 at 13:33 Comment(1)
Hi amr. Did you try doing it the same way than for other environment variables on github actions?Boehm
B
25

You can use the following run command to set a system path variable in your actions workflow.

Syntax:

echo "{path}" >> $GITHUB_PATH
- run: |
   echo "$AA/BB/bin" >> $GITHUB_PATH

Additionally, if you have downloaded some binaries and trying to set its path, GitHub uses a special directory called $GITHUB_WORKSPACE as your current directory. You may need to specify this variable in your path in that case.

- run: |
   echo "$GITHUB_WORKSPACE/BB/bin" >> $GITHUB_PATH
Bodrogi answered 1/7, 2021 at 17:9 Comment(0)
W
8

If you are using Bash shell

- name: Add to PATH
  shell: bash
  run: |
    echo "Folder PATH" >> $GITHUB_PATH

For Powershell as a shell:

- name: Add to PATH
  shell: pwsh
  run: |
    echo "Folder PATH" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
  
Wiley answered 7/10, 2022 at 2:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.