I’m trying to set up a GitHub Action to create NPM packages for different libraries in my Angular workspace. The build step works fine, but I’m running into issues with the publish step.
Here’s what’s happening:
The build process completes successfully
The dist folder is created and added to .gitignore
When trying to publish, I get an error saying the dist folder doesn’t exist
The error message is Error: Process completed with exit code 2.
I’m confused about why this is happening. The dist folder should be there after the build, right? Has anyone encountered this issue before? Any ideas on how to fix it?
hey man, i had the same problem. turns out the dist folder doesn’t carry over between jobs. try using actions/upload-artifact and actions/download-artifact to save and restore the dist folder. worked for me! good luck with ur publishing!
I’ve encountered this issue before, and it’s related to how GitHub Actions isolates job environments. Each job runs in a separate context, so the dist folder from your build job isn’t accessible in the publish job.
To resolve this, you need to persist the dist folder between jobs. Use GitHub’s artifact actions to upload and download the dist folder. Modify your workflow like this:
I’ve dealt with a similar issue before, and it’s likely related to how GitHub Actions handles job contexts. Each job runs in a fresh environment, so the dist folder created in your build job isn’t available in the publish job.
To fix this, you need to persist the dist folder between jobs. Use the actions/upload-artifact and actions/download-artifact actions to achieve this. Here’s how you can modify your workflow: