Skip to content

Commit

Permalink
Merge pull request #179 from supportingami/feat/eu-west1-deployment
Browse files Browse the repository at this point in the history
Feat/eu west1 deployment
  • Loading branch information
chrismclarke authored Mar 24, 2024
2 parents 7a903ee + 321990b commit adabc76
Show file tree
Hide file tree
Showing 79 changed files with 550 additions and 301 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
branches:
- main
concurrency:
group: lint-build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
if: "!contains(github.event.pull_request.labels.*.name, 'Test - preview')"
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/preview-webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generate static site preview for production site
name: Production Preview
on:
repository_dispatch:
types: [production_preview]
jobs:
run_if_failure:
if: ${{ !github.event.client_payload.passed }}
runs-on: ubuntu-latest
steps:
- env:
MESSAGE: ${{ github.event.client_payload.message }}
run: echo $MESSAGE
# TODO - trigger preview build
91 changes: 91 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Generate static site preview for production site
name: Production Preview
on:
workflow_call:
push:
branches: main
# Only keep one active build per ref (e.g. pr branch, push branch, triggering workflow ref)
concurrency:
group: preview-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Setup Node 18
uses: actions/setup-node@v3
with:
node-version: 18.x

#############################################################################
# Node Modules
# Manually restore any previous cache to speed install
# As immutable install will not change cache only save new cache if not hit
# Uses fine-grained methods from https://github.com/actions/cache
#############################################################################

- uses: actions/cache/restore@v3
id: cache
with:
path: ./.yarn/cache
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-yarn-v1-
- name: Install node modules
run: yarn install --immutable && npm i -g vercel
- uses: actions/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ./.yarn/cache
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }}

#############################################################################
# Gcloud Setup
# Populate service account credentials to file
# Authenticate to google servers
# Initialize gcloud cli
#############################################################################
- name: Setup Credentials
id: service-account
run: |
echo ${{secrets.GCP_SA_KEY_B64}} | base64 --decode > ./service-account.json
- name: GCP Auth
uses: "google-github-actions/auth@v2"
with:
project_id: "sami-website-365718"
credentials_json: ${{secrets.GCP_SA_KEY_B64}}
token_format: "access_token"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
version: ">= 363.0.0"

#############################################################################
# Export production
#############################################################################
# TODO - refactor actions - reusable build, export, deploy, hooks, pr generate etc.

# Export production and rename to match dev configuration (production-local)
- name: Import production data locally
run: |
echo "STRAPI_READONLY_TOKEN=${{secrets.STRAPI_READONLY_TOKEN}}" > config/docker.local.env
yarn scripts strapi export --environment docker --ci
cp config/docker.local.env config/development.local.env
cp data/db/sami-production.db data/db/sami-dev.db
- name: Build
run: yarn scripts cli build --environment=development --no-export --no-preview --no-deploy
# HACK - split build-deploy above for easier debugging
- name: Deploy
run: |
cd frontend
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
vercel build --token=${{ secrets.VERCEL_TOKEN }}
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
# NOTE - also possible to do without intermediate but requires interaction with live cloud-run api
# - name: Generate preview
# run: yarn scripts cli build --environment=docker --export --no-backend --no-preview --deploy
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ scripts/input
scripts/output
.vercel

service.yaml
service*.yaml
4 changes: 2 additions & 2 deletions _deprecated/ci/Pulumi.production.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config:
gcp:project: sami-website-365718
gcp:region: europe-west2
sami-website:GCS_STORAGE_BUCKET: sami_website_uploads
gcp:region: europe-west1
sami-website:GCS_STORAGE_BUCKET: sami_website_public
4 changes: 2 additions & 2 deletions _deprecated/ci/Pulumi.staging.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
config:
gcp:project: sami-website-365718
gcp:region: europe-west2
sami-website:GCS_STORAGE_BUCKET: sami_website_uploads_staging
gcp:region: europe-west1
sami-website:GCS_STORAGE_BUCKET: sami_website_public_staging
4 changes: 2 additions & 2 deletions _deprecated/ci/services/docker-strapi-image-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { PATHS } from "../utils";
* Prerequisites
* ```
* gcloud auth ... application-default (TO CONFIRM FROM GUIDE)
* gcloud auth configure-docker europe-west2-docker.pkg.dev
* gcloud auth configure-docker europe-west1-docker.pkg.dev
* ```
*
* https://github.com/pulumi/pulumi-docker/blob/master/examples/container-registries/gcp/ts/index.ts
*/
export function DockerStrapiImageBuild(envName: string) {
const location = gcp.config.region || "europe-west2";
const location = gcp.config.region || "europe-west1";
const repositoryId = `sami-website-${envName}`;
const project = gcp.config.project;

Expand Down
2 changes: 1 addition & 1 deletion _deprecated/ci/services/gcp-cloudrun-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function GCPCloudRunDeploy(image: docker.Image, envName: string, envVars:
});

// Location to deploy Cloud Run services
const location = gcp.config.region || "europe-west2";
const location = gcp.config.region || "europe-west1";
const fullImageName = image.imageName;

// Environment variables
Expand Down
2 changes: 1 addition & 1 deletion _deprecated/ci/utils/gcp-storage-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as gcp from "@pulumi/gcp";
*/

export function GCPCStorageCreate(bucketname: string) {
const location = gcp.config.region || "europe-west2";
const location = gcp.config.region || "europe-west1";
// Create a GCP resource (Storage Bucket)
const bucket = new gcp.storage.Bucket(bucketname, {
location,
Expand Down
5 changes: 5 additions & 0 deletions _deprecated/config/docker-compose.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Additional env required when running via docker-compose

# Domain pointed at server to generate https certs
PUBLIC_DOMAIN=next.sami.local
LETS_ENCRYPT_EMAIL=[email protected]
2 changes: 1 addition & 1 deletion _deprecated/config/staging.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DATABASE_URL=postgres://wspestjk:[email protected]
# If using a service worker will require access to bucket

GOOGLE_APPLICATION_CREDENTIALS=./service-account.json
GCS_BUCKET_NAME=sami_website_uploads_staging-bf0d161
GCS_BUCKET_NAME=sami_website_public_staging-bf0d161
GCS_PUBLIC_FILES=true
GCS_UNIFORM=false

Expand Down
8 changes: 3 additions & 5 deletions config/docker.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Domain pointed at server to generate https certs
PUBLIC_DOMAIN=next.sami.local
LETS_ENCRYPT_EMAIL=[email protected]


# Strapi Configuration
# NOTE - changes to these will require new strapi build (?)
Expand All @@ -22,13 +20,13 @@ DATABASE_FILENAME=sami-production.db
# Or exporting locally
GCP_PROJECT=sami-website-365718
GCS_DB_BUCKET_NAME=sami_website_db
GCS_PUBLIC_BUCKET_NAME=sami_website_uploads
GCS_PUBLIC_BUCKET_NAME=sami_website_public

# Paseed from compose
# STRAPI_READONLY_TOKEN=TO_BE_GENERATED

# Connect to API directly but serve image from public url
NEXT_PUBLIC_API_URL=http://backend:1337
NEXT_PUBLIC_API_URL=https://admin.samicharity.co.uk

# Images uploaded in backed are shared directly with frontend via volumes
# So just load from self
Expand Down
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ignorePaths": ["**/*.ts", "**/*.js", "**/dist"],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": ["strapi", "sami", "ami"],
"words": ["strapi", "sami", "ami", "vercel"],
"ignoreWords": [],
"import": []
}
12 changes: 10 additions & 2 deletions data/db-json/components_common_htmls.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
"id": 29
},
{
"html": "<h2 style=\"margin-left:0px;\">Background</h2><p><span style=\"color:hsl(0,0%,0%);font-family:&quot;Open Sans&quot;, Helvetica, Arial, Lucida, sans-serif;\">The African Data Initiative (ADI) is an on-going effort to help design and build statistical software that can easily be used throughout the developing world. It started through a crowd-funding campaign in November 2015, where close to £33,000 was raised to fund the initial development.</span></p><h2 style=\"margin-left:0px;\">Current Progress</h2><p style=\"margin-left:0px;\">The team in Kenya has been incredibly busy working on the software, and had their first <a href=\"http://www.africanmathsinitiative.net/blog/initiatives/african-data-initiative/\">beta release</a> in November 2016, one year on from the project start. Since then it has been showcased at numerous workshops and conferences, and received additional funding to support specific development to help explore climatic modelling and combat corruption.</p><p style=\"margin-left:0px;\">&nbsp;</p><p style=\"margin-left:0px;\"><img src=\"https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-danny-kisumu.png?resize=300%2C169&amp;ssl=1\" alt=\"Danny presents the software at a conference in Kenya\" srcset=\"https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-danny-kisumu.png?resize=300%2C169&amp;ssl=1 300w, https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-danny-kisumu.png?resize=768%2C432&amp;ssl=1 768w, https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-danny-kisumu.png?w=943&amp;ssl=1 943w\" sizes=\"(max-width: 300px) 100vw, 300px\" width=\"300\" loading=\"eager\"></p><p style=\"margin-left:0px;text-align:center;\">Danny presents the software at a conference in Kenya</p><p style=\"margin-left:0px;\">&nbsp;</p><p style=\"margin-left:0px;\"><img src=\"https://i2.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-dev-tanzania.png?resize=300%2C169&amp;ssl=1\" alt=\"The ADI team working together in Tanzania\" srcset=\"https://i2.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-dev-tanzania.png?resize=300%2C169&amp;ssl=1 300w, https://i2.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-dev-tanzania.png?resize=768%2C432&amp;ssl=1 768w, https://i2.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/ADI-dev-tanzania.png?w=944&amp;ssl=1 944w\" sizes=\"(max-width: 300px) 100vw, 300px\" width=\"300\" loading=\"eager\"></p><p style=\"margin-left:0px;text-align:center;\">The ADI team working together in Tanzania</p><p style=\"margin-left:0px;\">&nbsp;</p><h2 style=\"margin-left:0px;\">Future Plans</h2><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">R-Instat is looking towards its official release in July 2017 at the World Statistics Congress in Morocco.</span></p>",
"html": "<h2 style=\"margin-left:0px;\">Background</h2><p><span style=\"color:hsl(0,0%,0%);font-family:&quot;Open Sans&quot;, Helvetica, Arial, Lucida, sans-serif;\">The African Data Initiative (ADI) is an on-going effort to help design and build statistical software that can easily be used throughout the developing world. It started through a crowd-funding campaign in November 2015, where close to £33,000 was raised to fund the initial development.</span></p><h2 style=\"margin-left:0px;\">Current Progress</h2><p style=\"margin-left:0px;\">The team in Kenya has been incredibly busy working on the software, and had their first <a href=\"http://www.africanmathsinitiative.net/blog/initiatives/african-data-initiative/\">beta release</a> in November 2016, one year on from the project start. Since then it has been showcased at numerous workshops and conferences, and received additional funding to support specific development to help explore climatic modelling and combat corruption.</p>",
"id": 30
},
{
"html": "<h1 style=\"margin-left:0px;\">Background</h1><p style=\"margin-left:0px;\"><img src=\"https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/DCI.png?resize=300%2C217&amp;ssl=1\" alt=\"The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.\" srcset=\"https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/DCI.png?resize=300%2C217&amp;ssl=1 300w, https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/DCI.png?resize=768%2C555&amp;ssl=1 768w, https://i1.wp.com/samicharity.co.uk/wp-content/uploads/2016/03/DCI.png?w=874&amp;ssl=1 874w\" sizes=\"(max-width: 300px) 100vw, 300px\" width=\"300\" loading=\"eager\"></p><p style=\"margin-left:0px;text-align:center;\">The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.</p><p style=\"margin-left:0px;\">&nbsp;</p><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">In 2016 SAMI applied for a small grant from the Economist Charitable Trust to pilot a new project aimed at using technology to improve livelihoods across a community.</span></p><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">We initially started with a set of 20 android tablets that were taken out to the Kitale region of Western Kenya. We’ve been hard at work to find innovative and effective ways that the technology can be used to support people, with an initial focus on schools, agriculture and enterprising women.</span></p><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">Since then the project has expanded to include more than 60 devices, and we are working with organisations and institutions around the world to provide real impact, with costs involved kept to a minimum. You can see the first update report published by the DCI team below:</span></p><h1 style=\"margin-left:0px;\">Updates May 2017</h1><p style=\"margin-left:auto;\">&nbsp;</p><p style=\"margin-left:0px;\">Page <span style=\"background-color:transparent;\">1</span> / <span style=\"background-color:transparent;\">26</span></p><p style=\"margin-left:0px;\">&nbsp;</p><p style=\"margin-left:0px;\">Zoom <span style=\"background-color:transparent;\">100%</span></p><p style=\"margin-left:0px;\">&nbsp;</p><h1 style=\"margin-left:0px;\">Future Plans</h1><p style=\"margin-left:0px;\">We have been incredibly excited to see the huge impact&nbsp;seen through DCI, and are currently looking for ways to extend the project through 2017-2018.</p>",
"html": "<h1 style=\"margin-left:0px;\">Background</h1>",
"id": 31
},
{
Expand All @@ -142,5 +142,13 @@
{
"html": "<p style=\"margin-left:0px;\">For each camp we aim to have at least one experienced volunteer. Further, we aim to have at least one international teacher at each camp, either a current teacher or a retired teacher. We aim to also have two to three student international volunteers participate in each of the AMI camps, with the volunteers being a mixture of undergrads and postgrads/researchers. We would be happy to hear from people in other walks of life who feel they have something to contribute, and we would consider recommending high school students for this experience.</p><p style=\"margin-left:0px;\">The recruitment of international volunteers has begun and we will be considering applications on a rolling basis until the start of the camps.&nbsp;You can mention a preference for a camp in your application, but you don’t have to.&nbsp;Decisions on applications will be made by the SAMI Trustees, who then recommend suitable candidates to the local organisers of the respective camps. Note: all camps are run through local partners. As such, dates and venues are subject to change.&nbsp;</p><p style=\"margin-left:0px;\"><strong>Do not make any flight or accommodation booking until you have confirmed the camp dates with the local organiser</strong>.&nbsp;</p><p style=\"margin-left:0px;\">SAMI cannot accept responsibility for any financial loss occurred due to the changes in dates or venues for any of the camps.</p><p style=\"margin-left:0px;\">FAQs can&nbsp;be found below.&nbsp;If you would like to know more&nbsp;please write to&nbsp;<a href=\"mailto:[email protected]\">[email protected]</a>. We’re happy to give you more information by email and would be happy to meet you&nbsp;in person.</p>",
"id": 37
},
{
"html": "<h2 style=\"margin-left:0px;\">Future Plans</h2><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">R-Instat is looking towards its official release in July 2017 at the World Statistics Congress in Morocco.</span></p>",
"id": 38
},
{
"html": "<p style=\"margin-left:0px;text-align:center;\">The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.</p><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">In 2016 SAMI applied for a small grant from the Economist Charitable Trust to pilot a new project aimed at using technology to improve livelihoods across a community.</span></p><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">We initially started with a set of 20 android tablets that were taken out to the Kitale region of Western Kenya. We’ve been hard at work to find innovative and effective ways that the technology can be used to support people, with an initial focus on schools, agriculture and enterprising women.</span></p><p style=\"margin-left:0px;\"><span style=\"background-color:transparent;\">Since then the project has expanded to include more than 60 devices, and we are working with organisations and institutions around the world to provide real impact, with costs involved kept to a minimum. You can see the first update report published by the DCI team below:</span></p><h1 style=\"margin-left:0px;\">Updates May 2017</h1><p style=\"margin-left:auto;\">&nbsp;</p><p style=\"margin-left:0px;\">&nbsp;</p><h1 style=\"margin-left:0px;\">Future Plans</h1><p style=\"margin-left:0px;\">We have been incredibly excited to see the huge impact&nbsp;seen through DCI, and are currently looking for ways to extend the project through 2017-2018.</p>",
"id": 39
}
]
18 changes: 18 additions & 0 deletions data/db-json/components_common_images.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,23 @@
"caption": "\n",
"class_names": "max-w-lg",
"id": 12
},
{
"alt_text": null,
"caption": "Danny presents the software at a conference in Kenya",
"class_names": null,
"id": 13
},
{
"alt_text": null,
"caption": "The ADI team working together in Tanzania",
"class_names": null,
"id": 14
},
{
"alt_text": null,
"caption": "The Digital Communities Initiative uses technology to support across diverse areas including schools, agriculture and women in enterprise.",
"class_names": "max-w-md mx-auto",
"id": 15
}
]
Loading

0 comments on commit adabc76

Please sign in to comment.