Using a monorepo is my preferred way of managing code for my serverless projects (at least at the start when team size is small).
#TODO explain reasoning
---
## #OpenQuestions :
### How to selectively trigger [[AWS CodePipeline]] Pipelines in a Monorepo?
This is something that third party [[CICD]] providers such as [Seed](https://seed.run) offer (though I haven't tried it out myself).
Potential solution is to use script which detects folders between 2 Git IDs
- Can get the "to" ID from [[AWS CodePipeline]] [environment variable](https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html).
- But not sure how to get the "from" one.
- Do I need to store a LAST_DEPLOYED_VERSION to a state file in S3?
- Or at end of deploy, the build script could push a LAST_DEPLOYED tag to Github. But I think this complicates the Github integration as it's now 2-way and will need different GitHub permissions.
- Simple stateless version for now is to just use the previous Git commit ID in the history.
- Think I will need a parent "MonoRepoDetectChanges" CodePipeline with a single CodeBuild action that runs the git detection script and then uses aws cli to manually trigger the other pipelines. Think the other pipelines will need to have their source set to manual. Or alternative is to have an S3 bucket per each repo and have them triggered off that. Messy!
---
## Resources
- [How to end Microservice pain and embrace the Monorepo](https://www.fourtheorem.com/blog/monorepo?categoryId=91533) by Eoin Shanaghy, FourTheorem
- [CI/CD For Microservices Using Monorepos](https://blog.shippable.com/ci/cd-of-microservices-using-mono-repos)
- [SLIC Starter Repo Change Detection Script](https://github.com/fourTheorem/slic-starter/blob/561e6aa71ab5d6cb63fa853493f4f636e27f9a4d/build-scripts/source-kickoff.sh)
- https://blog.codecentric.de/en/2019/05/codebuild-trigger-pipeline/