Deploying to Google Cloud with Static Web Apps

This deployment example refers to Google Cloud Static Web Apps.

Prerequisites

Before you get started, you need to have:

Configuration

In your Custom Application config, provide the Custom Application ID you got when you configured the Custom Application in the Merchant Center.

custom-application-config.jsonjson
{
"env": {
"production": {
"applicationId": "ckvtahxl90097sys6har1e6n3",
"url": "https://<custom_domain>"
}
}
}

Using environment variables

In case you want to avoid hardcoding certain values, for example the Application ID, or the Project key, you can use variable placeholders in your Custom Application config.

custom-application-config.jsonjson
{
"env": {
"production": {
"applicationId": "${env:APPLICATION_ID}",
"url": "https://<custom_domain>"
}
}
}

Set up Google Cloud

To host the production bundles of your Custom Application you need to create a Cloud Storage bucket in Google Cloud and configure the bucket.

Configuring the bucket

Depending on the access options you choose, if you want to configure permissions, select the created bucket, go to the permissions tab and click the Add link. For the New principals field, select AllUsers and for the Role, search for Storage Object Viewer. Click Save to make the bucket publicly accessible.

Domain verification

Creating buckets with domain names requires to verify the ownership of the domain.

Google does not provide a domain by default when using Google Cloud Storage. If you don't have an existing domain, then there are many services through which you can register a new domain, such as Google Domains.

We recommend following the instructions for Domain-named bucket verification to configure things properly.

Another way to verify your domain is by using a load balancer. You have the chance to upload an SSL certificate to your load balancer. If you are using Google Domain Name Service, in your domain configuration, add a new record that points your domain to the IP address of the load balancer you created.

Connect Google Cloud with GitHub Actions

One of the ways to deploy to Google Cloud Storage (GCS) is to use Cloud Storage Uploader GitHub Action. Follow the instructions to integrate it with your repository CI.

Configuring rewrite rules

A Custom Application is a Single-Page Application that uses client-side routing. Therefore, you need to edit website configuration for your bucket to rewrite all requests to serve the index.html.

Production bundles

The main command to create the production bundles is mc-scripts build. The output folder is public.
See Going to production for more information.

Test your deployment

In the Merchant Center, you can now follow the steps to install the Custom Application and access it in your Projects.

The Custom Application won't render if you try to access it directly via the deployment URL, as it needs to be served within the Merchant Center Proxy Router.

Therefore, Preview deployments are not really useful. If you are interested in this functionality, let us know and open a support issue.