Ad

How To Save Build Files (React) Using Github Actions

I am trying to build react code using github actions. But after successfully building the files i want to save it in a particular location say "build" folder in the repo. I am currently able to build the files but not save them in the repo

Ad

Answer

If you would like to try and commit your build artifacts back to the repository yourself in a workflow see the following answer for how to prepare the repository and git config.

Push to origin from GitHub action

Alternatively, you might find create-pull-request action useful for this use case. It will commit changes to the Actions workspace to a new branch and raise a pull request. So if you call create-pull-request action after creating your artifacts during a workflow, you can have that change raised as a PR for you to review and merge.

For example:

on: release
name: Update Version
jobs:
  createPullRequest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      ...
      (your build steps)
      ...
      - name: Create Pull Request
        uses: peter-evans/[email protected]
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: Add build artifact
          title: Add build artifact
Ad
source: stackoverflow.com
Ad