I am trying to create a Dockerfile based action that adds a program to the $PATH so that it can be used by later actions. My action runs code like this:
mkdir -p $GITHUB_WORKSPACE/bin
echo "echo Hello, world!" > $GITHUB_WORKSPACE/bin/hello-world
echo "::add-path::$GITHUB_WORKSPACE/bin"
My test workflow uses this like so:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Add program to path
uses: ./
- name: Use program
run: hello-world
This fails because while the program has been added to $GITHUB_WORKSPACE/bin/hello-world the value of $GITHUB_WORKSPACE is different in the action and in the workspace step.
In the action it is /github/workspace/, while in the workflow it is /home/runner/work/setup-gleam/setup-gleam/, so the $PATH addition set by the action is not correct.
How can I add a file to a directory from a dockerfile based GitHub action so that it is on the path for the rest of the workflow? It seems that there is no writable $PATH directory shared between dockerfile actions and non-dockerfile actions.
Runner path is stored in $RUNNER_WORKSPACE environment variable and can be used to get the right path.
echo "::add-path::$GITHUB_WORKSPACE/bin" # Make it accessible from docker containers
echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" # Make it accessible from runner
But it looks more like a workaround than solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With