Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 4

How do I point the workflow .yml to a package.json in a subdirectory?

Solved! Go to Solution.

Say I have two packages in my repo.

1. Client

2. Server

 

I want an action to run only on the tests defined in the server/package.json. Can I achieve this? 

3 Replies
Highlighted
GitHub Partner
Message 2 of 4

Re: How do I point the workflow .yml to a package.json in a subdirectory?

@suhan0694 ,

Do you have published the two packages to GitHub Packages registry in the repository, or you just store the source code of them in the repository?

Can you share your repository with us so that we can check more details about the packages and the workflow you have set up.

Highlighted
Copilot Lvl 2
Message 3 of 4

Re: How do I point the workflow .yml to a package.json in a subdirectory?

Hello @BrightRan ,

 

I am not using Github package registry, just storing the source code in the repository.

 

Here is a link for the REPO https://github.com/suhan0694/mern-boilerplate.

 

Highlighted
Solution
GitHub Partner
Message 4 of 4

Re: How do I point the workflow .yml to a package.json in a subdirectory?

@suhan0694 ,

Looks like, you define the tests in the scripts property of the package.json file. If you want to run the scripts in the Server package, you can try the following steps:

1. Use checkout action to check out the repository to the workspace (github.workspace or GITHUB_WORKSPACE) of the workflow.

2. Switch the working-directory of the shell to the directory where the package.json file of Server is located, for example execute cd server in your case.

3. Execute the npm-run-script command to run the scripts in the package.json file.

 

Hope this can help you.