https://github.com/axelniklasson/monorepo-yarn-workspaces-turborepo
Monorepo template for building a JS monorepo with yarn workspaces, Tubrorepo and GitHub Actions.
https://github.com/axelniklasson/monorepo-yarn-workspaces-turborepo
github-actions monorepo template turborepo yarn-workspaces
Last synced: 2 months ago
JSON representation
Monorepo template for building a JS monorepo with yarn workspaces, Tubrorepo and GitHub Actions.
- Host: GitHub
- URL: https://github.com/axelniklasson/monorepo-yarn-workspaces-turborepo
- Owner: axelniklasson
- Created: 2021-12-22T10:05:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T15:15:48.000Z (over 2 years ago)
- Last Synced: 2025-03-21T22:41:31.037Z (3 months ago)
- Topics: github-actions, monorepo, template, turborepo, yarn-workspaces
- Language: JavaScript
- Homepage:
- Size: 978 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Monorepo with yarn workspaces and Turborepo
This repo is a boilerplate for how a JS monorepo can be setup using [yarn workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/) and [Turborepo](https://turborepo.org/) along with GitHub actions for CI/CD and manual deployment triggers.## Tooling
### generate-project
The bundled `generate-project` script can be used to scaffold apps/packages with minimal sample code. To modify the templates, head on over to `tools/generate-project/templates` and modify accordingly.```
➜ yarn generate-project
yarn run v1.22.17
$ node ./tools/generate-project/generate.js
Hi, welcome to generate-project
? What do you want to generate? Package
? What's the name of the project? utils
Success! Please run `yarn` in the project root.
✨ Done in 2.34s.➜ yarn
yarn install v1.22.17
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
✨ Done in 3.60s.➜ yarn workspace @monorepo/utils test
yarn workspace v1.22.17
yarn run v1.22.17
warning package.json: No license field
$ jest
PASS ./index.test.js
utils
✓ it sums correctly (2 ms)Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.818 s
Ran all test suites.
✨ Done in 1.79s.
✨ Done in 2.02s.
```## Turbo pipeline
The Turbo pipeline has been setup to run the following
```
lint -> test -> build -> deploy
```
in sequenece, so for every successful build both linting and tests will also have been run. When deploying, the build task is first invoked to ensure that whatever is being deployed does not have any issues.## CI workflow
### Pushes
Whenever a commit is pushed to a branch, the following happens;
- If the branch *does not* have a parent (i.e. the `main` branch), `yarn turbo run build` is run which triggers a build in every app/package in the monorepo
- If the branch *does* have a parent, `yarn turbo run build --since=origin/` is run which triggers a build in every app/package that has been changed since branched out from the parent branch### Pull requests
Whenever a pull request is opened, the following happens:
- `yarn turbo run build --since=origin/` is run which triggers a build in every app/package in the monorepo that would be changed if the PR would be merged into the base branch## CD and manual deployments
### CD
The monorepo is configured to automatically deploy projects whenever a tag is pushed to the `main` branch. Each tag **must** follow the `/` naming convention, as tag name parsing is done by the workflow to figure out which version of which app should be deployed. For example, to deploy `v1.0.0` of `express-app` you would do the following:```
git checkout main && git pull
git tag express-app/v1.0.0 && git push --tags
```Note that creating a tag on a branch other than `main` will **not** trigger a deploy.
### Manual deployments
To trigger a manual deployment of a project in the monorepo, go to the .1. Go to the [Manual deployment action](https://github.com/axelniklasson/monorepo-yarn-workspaces-turborepo/actions/workflows/manual_deploy.yml)
2. Click "Run workflow"
3. Fill out project name and environment to deploy to
4. Click "Run workflow" again and the deployment is kicked off!