The default all commands are executed at root directory of the application. In some cases, you need to execute any command for the sub directories. It’s possible by setting the working-directory directive in the configuration file.

Running Command in Subdirectory with Github Actions

For example, your application have composer.json file under the “app” directory. In that case, use the following configuration to run composer install under app directory.

In the above configuration the “composer install –no-scripts” command will be executed under “./app” directory. You can set any directory path by changing the value of working-directory. Below is a complete action configuration file used in our actual project.

Conclusion

In this tutorial, you have learned running commands in subdirectory with Github actions.