Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Action- How to restart the session?

I have a Github Action that creates a dotnet tool, and trying to use it.

$ dotnet pack MyTool.csproj --configuration Release
$ dotnet tool install --global --add-source . MyTool

Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.
You can invoke the tool using the following command: my-tool
Tool 'MyTool' (version '1.0.0') was successfully installed.

$ my-tool

my-tool: command not found

How can I logout or restart my session in the job, to reload the PATH?

like image 873
baruchiro Avatar asked Nov 23 '19 18:11

baruchiro


People also ask

How do I restart an action in GitHub?

To re-run a failed workflow run, use the run rerun subcommand. Replace run-id with the ID of the failed run that you want to re-run. If you don't specify a run-id , GitHub CLI returns an interactive menu for you to choose a recent failed run.

Why are my actions not running on GitHub?

So if you are copypasting actions from elsewhere, make sure that you are targeting the correct branch (for new repos this means most of the time to replace master with main in the . yml workflow files). If you are targeting the wrong branch, the name of the action will appear on GitHub but no actions will actually run.

Where are GitHub runners located?

A self-hosted runner can be located in either your repository, organization, or enterprise account settings on GitHub.


1 Answers

In the section called Install a global tool, it says that the tools are installed at the following locations:

OS Path
Linux/macOS $HOME/.dotnet/tools
Windows %USERPROFILE%\.dotnet\tools

Below that, it also says:

This location is added to the user's path when the SDK is first run, so global tools can be invoked from any directory without specifying the tool location.

However, it looks like from your output that you also just installed the .NET SDK so it hasn't had a chance to add those folders to the PATH.

There are two ways of doing this that immediately come to mind:

  1. Since you already know where the tools are installed, just use the absolute path to the tool you just installed: $HOME/.dotnet/tools/my-tool

  2. Another way is to fix the PATH before running the tool so that when you get to the step that installed the tool, it is already available. In your workflow, there are many ways of modifying the PATH, but the easiest seems to be to modify the $GITHUB_PATH file. So in a previous step, do the following inside run

    run:
       ...
       mkdir --parents $HOME/.dotnet/tools
       echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
    

After this is done, the next step, should be able to access the tool after installing it.

like image 80
smac89 Avatar answered Oct 16 '22 13:10

smac89