This GitHub Actions workflow automates the process of building your project and updating the build files in the main branch. It's triggered on pushes to the main branch that affect files in the src/
directory, or manually via workflow dispatch.
-
The workflow is triggered on:
- Push events to the
main
branch (only when files insrc/
are changed) - Manual trigger (workflow_dispatch)
- Push events to the
-
It sets up a Node.js environment and installs dependencies.
-
The build process is run using
npm run build
. -
If there are changes in the build files, it:
- Creates a new branch
- Commits the changes
- Opens a pull request
- Automatically merges the pull request
-
Add this workflow file to your repository at
.github/workflows/automatic-build.yml
. -
Ensure your project has a
build
script inpackage.json
:{ "scripts": { "build": "your-build-command-here" } }
-
Push changes to the src/ directory in the main branch to trigger the workflow.
-
Alternatively, manually trigger the workflow from the Actions tab in your GitHub repository.
Both of these settings need to be setup in the way that allows github actions to automatically merge pull requests, below is my setup: