This project follows the DEV.to #ActionsHackathon21 hackathon.
Use GitHub Actions and Workflows to build and deploy your applications to a branch. So you can just pull this branch to deploy on the production server, without building. You can also use it to deploy to Github Pages, by selecting the destination branch as the Github Pages's branch.
Check the complete workflow here (build-and-deploy-to-branch.yml)
- actions/checkout@v2 To checkout the source code from the repository
- actions/cache@v2 To cache the dependencies, allow us to re use them for future builds
(Also actions/setup-node@v2 for setup nodejs, although it's not required)
- You can config the deployment branch postfix, with
DEPLOY_BRANCH_POSTFIX
variable. So the code on "main" branch will be built and pushed intomain-<DEPLOY_BRANCH_POSTFIX>
branch - You can also configure the branches which you want to run this workflow, with
branches
key.
In this repository, I use a sample NextJS to demonstrate. However you can change the workflow a bit to fit your project.
- Use actions/checkout@v2 to checkout source code from the repository
- Use actions/setup-node@v2 to setup nodejs
- Use actions/cache@v2 to cache dependencies (
node_modules
and.yarn
directories) - Install dependencies with
yarn
- Run tests
- Build application
- Synchronize built files with deployment branch
- Push build into the deployment branch