Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 3.31 KB

README.md

File metadata and controls

69 lines (47 loc) · 3.31 KB

Affresco CI setup

All the CI for all the apps in this repo is run on GitHub Actions.

We have two CI workflows:

Editing the workflows

Since the workflows include a bunch of boilerplate, we do not edit the YAML files by hand, but instead we generate those files from some Dhall definitions. To generate these files locally, without Nix, run make generate-ci-local.

The template for the pull-requests CI is here, while the one for production is here.

The list of the deployments is here - and this is the file that should be edited when adding a new app. For documentation on the machinery that we use to generate the CI workflows, see this file

The two workflow are slightly different. They both:

  • setup the CI environment
  • check that the generated workflows are up to date with the Dhall source (do this with make generate-ci-local)
  • build all the apps
  • upload them to a bucket

Then the "preview" workflows posts a comment to the PR with the link to the newly deployed previews, while the "production" workflows clears the CDN cache so that the new version of the apps goes live.

Environment variables

The global environment variables (i.e. the ones shared by more than one app) should go in every workflow's env key, while the ones belonging to a single app should go in the apps.dhall file.

Build caching

We globally cache all node_modules, .yarn-cache and .cache folders keyed to the hash of the global yarn.lock

Individual build caches can be configured separately for each app in apps.dhall by adding a refenece to a "lockfile" and the paths that require caching.

Individual build caching for AppEngine builds is still a WIP.

Adding a new app

  1. Edit the apps.dhall file to add the new app details
  2. You'll find the production app deployed at https://frontends.ksfmedia.fi/$deployDir/index.html

If you need to redirect index.html to the /, you can add a rewriting rule to the ksf-frontends-lb load balancer (in the ksf-production project)

Getting a "nice url" for the app

Sometimes you need a nicer URL for the deployed frontend, e.g. as it's the case for Mitt Konto.

In this situation you'll need to add a new CDN setup in Google Cloud. Steps:

  1. Create a new "Cloud CDN" resource backed by the ksf-frontends bucket
  2. For this you'll need to create new load balancer. You'll need to add a new "host and path rule", where:
  • the host is the one you need for the app
  • the path rules are:
    • path / with a URL rewrite to $deployDir/index.html (note that deployDir is one of the configurations of an app, and ultimately the location of it in the bucket)
    • path /* with a URL rewrite to /$deployDir/ (note the slashes, they seem to be important)
  1. Create a new SSL certificate for the new host on this load balancer, and point a DNS A record to the IP of the load balancer
  2. Edit the refreshCDNSteps source to include a gcloud command to clear the CDN cache on new deployments

Maintenance Mode

Change the MAINTENANCE_MODE env var to true for the desired app in apps.dhall