tanwanimohit / deploy-react-to-ghpages

This Action will automate the process of building and depolying react app to gh-pages.
https://github.com/marketplace/actions/deploy-react-app-to-github-pages
MIT License
24 stars 12 forks source link

Remove Dependency on package.json "build" Script #5

Closed atb-brown closed 1 year ago

atb-brown commented 1 year ago

Description

Previously, there was a step that ran npm run build, but this assumes that the consumer has a build script in their package.json. While this is usually a same assumption since many people start off using create-react-app which initializes the package.json with the build script, some consumers may change the name of that script.

With this commit, the step is no longer running an npm script but, instead, uses npx to run the react-scripts package directly to invoke the react-script build script. With this change, consumers do not need to keep the build script configured in their package.json. Of course, even if they do continue to have that script, this change will still work for those consumers passively.

Testing

I tested this by pushing my fork's branch (https://github.com/atb-brown/deploy-react-to-ghpages/commit/9afaf230b36c45a3bf2a896bcd4750536334ad0c) and then including it in my project's deployment action - https://github.com/atb-brown/austin/commit/1fac733a59bcf4cf7ba799719b07147791ccef3b

Then, with my changes, I noticed that it worked because the pages-build-deployment action kicked off and succeeded: https://github.com/atb-brown/austin/actions/runs/4586446808 image

And then the visual change that I made showed up (normal the React logo is in the top left corner): image