Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove Netlify deploy code #2781

Merged
merged 6 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ help:
@echo ' make refresh.wp download a new wordpress snapshot and update MySQL'
@echo ' make refresh.full do a full MySQL update of both wordpress and grapher'
@echo
@echo ' OPS (staff-only)'
@echo ' make deploy Deploy your local site to production'
@echo ' make stage Deploy your local site to staging'
@echo

up: export DEBUG = 'knex:query'

Expand Down Expand Up @@ -219,36 +215,6 @@ wordpress/web/app/uploads/2022:
@echo '==> Downloading wordpress uploads'
./devTools/docker/download-wordpress-uploads.sh

deploy:
@echo '==> Starting from a clean slate...'
rm -rf itsJustJavascript

@echo '==> Building...'
yarn
yarn lerna run build
yarn run tsc -b

@echo '==> Deploying...'
yarn buildAndDeploySite live

stage:
@if [[ ! "$(STAGING)" ]]; then \
echo 'ERROR: must set the staging environment'; \
echo ' e.g. STAGING=halley make stage'; \
exit 1; \
fi
@echo '==> Preparing to deploy to $(STAGING)'
@echo '==> Starting from a clean slate...'
rm -rf itsJustJavascript

@echo '==> Building...'
yarn
yarn lerna run build
yarn run tsc -b

@echo '==> Deploying to $(STAGING)...'
yarn buildAndDeploySite $(STAGING)

test:
@echo '==> Linting'
yarn
Expand Down
67 changes: 4 additions & 63 deletions baker/DeployUtils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import fs from "fs-extra"
import { BakeStepConfig, SiteBaker } from "../baker/SiteBaker.js"
import { BuildkiteTrigger } from "../baker/BuildkiteTrigger.js"
import { logErrorAndMaybeSendToBugsnag, warn } from "../serverUtils/errorLog.js"
import { DeployQueueServer } from "./DeployQueueServer.js"
import {
BAKED_SITE_DIR,
BAKED_BASE_URL,
BUILDKITE_API_ACCESS_TOKEN,
} from "../settings/serverSettings.js"
import { DeployChange, OwidGdocPublished } from "@ourworldindata/utils"
import { Gdoc } from "../db/model/Gdoc/Gdoc.js"
import { BUILDKITE_API_ACCESS_TOKEN } from "../settings/serverSettings.js"
import { DeployChange } from "@ourworldindata/utils"

const deployQueueServer = new DeployQueueServer()

Expand All @@ -31,7 +25,7 @@ const defaultCommitMessage = async (): Promise<string> => {
/**
* Initiate a deploy, without any checks. Throws error on failure.
*/
const bakeAndDeploy = async (
const triggerBakeAndDeploy = async (
message?: string,
lightningQueue?: DeployChange[]
) => {
Expand All @@ -53,59 +47,6 @@ const bakeAndDeploy = async (
buildkite.runFullBuild(message).catch(logErrorAndMaybeSendToBugsnag)
}
}

const baker = new SiteBaker(BAKED_SITE_DIR, BAKED_BASE_URL)
try {
if (lightningQueue?.length) {
for (const change of lightningQueue) {
const gdoc = (await Gdoc.findOneByOrFail({
published: true,
slug: change.slug,
})) as OwidGdocPublished
await baker.bakeGDocPost(gdoc)
}
} else {
await baker.bakeAll()
}
await baker.deployToNetlifyAndPushToGitPush(message)
} catch (err) {
logErrorAndMaybeSendToBugsnag(err)
throw err
}
}

export const bake = async (bakeSteps?: BakeStepConfig) => {
const baker = new SiteBaker(BAKED_SITE_DIR, BAKED_BASE_URL, bakeSteps)
try {
await baker.bakeAll()
} catch (err) {
baker.endDbConnections()
logErrorAndMaybeSendToBugsnag(err)
throw err
} finally {
baker.endDbConnections()
}
}

/**
* Try to initiate a deploy and then terminate the baker, allowing a clean exit.
* Used in CLI.
*/
export const tryDeploy = async (
message?: string,
email?: string,
name?: string
) => {
message = message ?? (await defaultCommitMessage())
const baker = new SiteBaker(BAKED_SITE_DIR, BAKED_BASE_URL)

try {
await baker.deployToNetlifyAndPushToGitPush(message, email, name)
} catch (err) {
logErrorAndMaybeSendToBugsnag(err)
} finally {
baker.endDbConnections()
}
}

const generateCommitMsg = (queueItems: DeployChange[]) => {
Expand Down Expand Up @@ -160,7 +101,7 @@ export const deployIfQueueIsNotEmpty = async () => {
const message = generateCommitMsg(parsedQueue)
console.log(`Deploying site...\n---\n${message}\n---`)
try {
await bakeAndDeploy(
await triggerBakeAndDeploy(
message,
// If every DeployChange is a lightning change, then we can do a
// lightning deploy. In the future, we might want to separate
Expand Down
15 changes: 0 additions & 15 deletions baker/Deployer.test.ts

This file was deleted.

Loading