Skip to content

Commit

Permalink
Revert "Move deploy to run (#139679)" (#139687)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsummers1 authored Jul 3, 2024
1 parent 6bc7395 commit f5de019
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: |
# When deploying multiple copies of this quickstart to the same AWS Account (not ideal), a prefix helps prevent stepping on each other.
# This can optionally be set as an GitHub Actions Secret
./run deploy --stage $STAGE_PREFIX$branch_name
./deploy.sh $STAGE_PREFIX$branch_name
- id: endpoint
run: |
APPLICATION_ENDPOINT=$(./output.sh ui ApplicationEndpointUrl $STAGE_PREFIX$branch_name)
Expand Down
59 changes: 59 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

stage=${1:-dev}

services=(
'database'
'app-api'
'uploads'
'ui'
'ui-auth'
'ui-src'
)

install_deps() {
if [ "$CI" == "true" ]; then # If we're in a CI system
if [ ! -d "node_modules" ]; then # If we don't have any node_modules (CircleCI cache miss scenario), run yarn install --frozen-lockfile. Otherwise, we're all set, do nothing.
yarn install --frozen-lockfile
fi
else # We're not in a CI system, let's yarn install
yarn install
fi
}

prepare_service() {
service=$1
pushd services/$service
install_deps
popd
}

install_deps
export PATH=$(pwd)/node_modules/.bin/:$PATH

for i in "${services[@]}"
do
prepare_service $i
done

serverless deploy --stage $stage

# Only deploy resources for kafka ingestion in real envs
if [[ "$stage" == "main" || "$stage" == "val" || "$stage" == "production" ]]; then
kafkaservice='carts-bigmac-streams'
prepare_service $kafkaservice
pushd services/$kafkaservice
serverless deploy --stage $stage
popd
fi

pushd services
echo """
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Application endpoint: `./output.sh ui CloudFrontEndpointUrl $stage`
------------------------------------------------------------------------------------------------
"""
popd
57 changes: 0 additions & 57 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ import { execSync } from "child_process";
// load .env
dotenv.config();

const deployedServices = [
"database",
"uploads",
"app-api",
"ui",
"ui-auth",
"ui-src",
];

// Function to update .env files using 1Password CLI
function updateEnvFiles() {
try {
Expand Down Expand Up @@ -126,46 +117,6 @@ async function run_all_locally() {
run_fe_locally(runner);
}

async function deploy_kafka_service(
runner: LabeledProcessRunner,
stage: string
) {
const kafkaservice = "carts-bigmac-streams";
install_deps(runner, kafkaservice);
const kafkaDeployCmd = ["sls", "deploy", "--stage", stage];
await runner.run_command_and_output(
"Kafka service deploy",
kafkaDeployCmd,
`services/${kafkaservice}`
);
}

async function install_deps(runner: LabeledProcessRunner, service: string) {
await runner.run_command_and_output(
"Installing Dependencies",
["yarn", "install", "--frozen-lockfile"],
`services/${service}`
);
}

async function prepare_services(runner: LabeledProcessRunner) {
for (const service of deployedServices) {
install_deps(runner, service);
}
}

async function deploy(options: { stage: string }) {
const stage = options.stage;
const runner = new LabeledProcessRunner();
await prepare_services(runner);
const deployCmd = ["sls", "deploy", "--stage", stage];
await runner.run_command_and_output("SLS Deploy", deployCmd, ".");
// Only deploy resources for kafka ingestion in real envs
if (stage === "main" || stage === "val" || stage === "production") {
deploy_kafka_service(runner, stage);
}
}

async function destroy_stage(options: {
stage: string;
service: string | undefined;
Expand Down Expand Up @@ -202,14 +153,6 @@ yargs(process.argv.slice(2))
run_all_locally();
})
.command("test", "run all tests", () => {})
.command(
"deploy",
"deploy the app with serverless compose to the cloud",
{
stage: { type: "string", demandOption: true },
},
deploy
)
.command(
"destroy",
"destroy serverless stage",
Expand Down

0 comments on commit f5de019

Please sign in to comment.