Hi, and thanks for contributing to primer.style
!
This site is built with Gatsby and [Primer React].
To start up your local dev environment, run:
npm install
to install all the Node dependenciesnpm run dev
to start the dev servernpm run build
to build the static sitenpm start
to serve the static site
This site is deployed to Microsoft App Service on Azure and mapped to the primer.style
domain.
There are three ways to deploy this site:
Syntax | Trigger |
---|---|
Production | merge to main branch |
Staging | merge to staging branch |
Preview | pull request from any branch into main |
Reverse-proxy URL rewriting allows us to serve multiple apps under a single domain (in this case, primer.style
). As this site grows, we will split larger pages off into separate apps and manage their aliases in this repo's web.config. We recommend deploying these separate apps to GitHub Pages.
The following steps describe how to reverse-proxy an externally-hosted app as a new page route to primer.style. This example assumes that your app will be served from primer.style/your-app-name
.
-
Deploy your app to GitHub Pages, or another hosting provider so that it is accessible on a unique origin URL. E.g.
https://primer.github.io/your-app-name
-
Ensure that your app is deploying to a subfolder that corresponds to the one you would like to use on primer.style. E.g. Deploy to
/your-app-name/
, and not to/
. -
Add a new entry to
web.config
:<rule name="Your app proxy" stopProcessing="true"> <match url="^your-app-name/(.*)" ignoreCase="true" /> <conditions> <add input="{HTTP_HOST}" pattern="^(?:www.)?(.*)$" /> </conditions> <action type="Rewrite" url="https://primer.github.io/your-app-name/{R:1}" /> <serverVariables> <set name="HTTP_X_UNPROXIED_URL" value="https://primer.github.io/your-app-name/{R:1}" /> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" /> <set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" /> <set name="HTTP_ACCEPT_ENCODING" value="" /> </serverVariables> </rule>
-
Deploy the changes to the
staging
environment on Azure to verify the rewrite works. This can be done by merging your changes to thestaging
branch. This will deploy to https://primerstyle-staging.azurewebsites.net/your-app-name -
Deploy the changes to the
production
environment on Azure by merging your changes into themain
branch. This will deploy to https://primer.style/your-app-name
Because of the way that GitHub Pages deploys websites to a subfolder named after the repository, separate apps need to be configured to serve all of their URLs under the same path as they're aliased to on primer.style
. In other words, an app aliased to /alias/**
will need to serve all of its content from /alias/
rather than /
. For both Gatsby and Next.js, this means nesting all of your page content in pages/<alias>/
.