Static-web-apps: Mono repo support

Created on 21 May 2020  路  11Comments  路  Source: Azure/static-web-apps

My scenario: I鈥檓 deploying two apps: Sanity studio, a cms admin UI, as well as the frontend (next.js) accessing the headless CMS apis of Sanity.

I cannot create two sites in Azure Linked to the same repo, due to some restrictions (the error message does not indicate how I can fix it, or if possible at all).

John Papa mentioned there is a workaround using different branches, but it would be better if both apps were following the master branch, so I don鈥檛 have to adjust my git flow for the sake of this working.

Thanks!

Most helpful comment

So you can customize your workflow to your needs as described above. All that has changed is that you can add multiple Static Web Apps to the same repository + branch. The experience from there is that when you push to that branch (or create a pull request) both sites will get updated/have a staging environment, but you can edit that by specifying which paths to consider in each workflow file.

No change to the creation experience!

All 11 comments

Thanks for adding this @johnkors !

I also have a monorepo and I'd love to deploy multiple projects from it, from different folders. It would be nice to have a CI/CD process that would allow for building one or the other, at a time.

Some questions for you:

Would you want to deploy it all at once?

Would you want to deploy one app by itself, and not others in the monorepo?

What would trigger builds?

I think this should be up to the developers to decide. If they want to always deploy all, or deploy specific apps, they'll just setup their ymls to do so.

As far as I understood, GitHub actions already supports trigger on file paths. One could for example do individual github action ymls, with specific triggers like:

_.github/workflows/app1-deploy.yml_

on:
 push
  branches:
  - master
  paths:
  - app1/**

_.github/workflows/app2-deploy.yml_

on:
 push
  branches:
  - master
  paths:
  - app2/**

So, on the GitHub side of things, this is all done and ready. It's just Azure not allowing for the use of it (why?).

Here is a sample monorepo project we could use for testing of many apps https://github.com/johnpapa/hello-worlds

I second this request : we have a monorepo too, and trying to create a second SWA tied to the repo doesn't work. Same ideas and feedbacks as @johnkors

In front-end development, we are increasingly using monorepo. For example, if you want to share components between the end-user app and the admin app. So I want this Issue to be a higher priority.

Same problem. Iam trying to deploy two web static applications sharing components in a monorepo approach. Azure wont let me do so, didnt find any workaround so i'll have to break my monorepo or switch to another platform... :(

Same problem :(

We have monorepo support now for all newly created Static Web Apps! You may run into an issue if you have a previously created (before this week) Static Web App attached to the repo/branch you want to use for your monorepo. If you run into that issue, just delete the old Static Web App and the newly created one(s) should then be unblocked.

@miwebst - Thank you! Can you share how this support works and what settings in the workflow file would change for this?

Will the creation experience change in some way?

So you can customize your workflow to your needs as described above. All that has changed is that you can add multiple Static Web Apps to the same repository + branch. The experience from there is that when you push to that branch (or create a pull request) both sites will get updated/have a staging environment, but you can edit that by specifying which paths to consider in each workflow file.

No change to the creation experience!

@miwebst Excellent! Thanks for the quick response. Now I can move forward with my product.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

henryjcee picture henryjcee  路  5Comments

simonaco picture simonaco  路  4Comments

thomastvedt picture thomastvedt  路  5Comments

wictorwilen picture wictorwilen  路  3Comments

trevorkennedy picture trevorkennedy  路  4Comments