56

In Maven, I need to provide absolute path to a directory in my project. How can I get absolute path to the directory GitHub action is running in?

4
  • 4
    Did you try using the $GITHUB_WORKSPACE env var? Commented May 18, 2021 at 15:53
  • Yes, but some reason empty string is passed in this case -DSteam.path=${{ env.GITHUB_WORKSPACE }}/lib Commented May 18, 2021 at 16:54
  • 3
    Did you use the checkout/actions on your workflow before accessing the $GITHUB_WORKSPACE? Did you try to save the path as local variable before using it in your workflow? (If yes, could you edit your question with your workflow to see how you did it?) Commented May 18, 2021 at 17:05
  • For some reason using ${GITHUB_WORKSPACE} helped. Thanks! Commented May 18, 2021 at 17:52

2 Answers 2

60

As pointed out by @soltex, ${GITHUB_WORKSPACE} points to the checkout directory.

Sign up to request clarification or add additional context in comments.

Comments

33

In addition to the environment variable described by @Evgeny Bovykin, you can also use the ${{ ...}} syntax with:

${{ github.workspace }}

See the documentation.

1 Comment

This was the one that worked for me. Think it might have something to do with the above answer only working inside an actual run: script whereas yours workers even outside of an actual workflow.

Your Answer

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.