Amplify Monorepo built the wrong app

0

Hi,

Would like to ask with regards to Amplify build issue. We have 3 different app using monorepo and hosted on Amplify. In the repository itself we define all apps build configuration in single amplify.yml. We also put AMPLIFY_MONOREPO_APP_ROOT environment variable for each of the app. During deployment we use Amplify CLI to trigger the build. We created a bash script to loop the application id list and execute aws amplify start-job command.

The issue is, intermittently, somehow, one of the app use wrong build command (amplify picked from another app) and causing us to have the wrong app deployed, although we already put the correct app root in amplify.yml and env var as well. This issue didn't occurred when we do manual deployment using Amplify UI.

Here is the amplify.yml:

version: 1
applications:
  - appRoot: workspaces/customer
    frontend:
      phases:
        preBuild:
          commands:
            - nvm install lts/gallium
        build:
          commands:
            - yarn
            - yarn build:packages
            - yarn workspace customer run build
      artifacts:
        baseDirectory: build
        files:
          - '**/*'
  - appRoot: workspaces/ops
    frontend:
      phases:
        preBuild:
          commands:
            - nvm install lts/gallium
        build:
          commands:
            - yarn
            - yarn build:packages
            - yarn workspace ops run build
      artifacts:
        baseDirectory: build
        files:
          - '**/*'
  - appRoot: workspaces/partner
    frontend:
      phases:
        preBuild:
          commands:
            - nvm install lts/gallium
        build:
          commands:
            - yarn
            - yarn build:packages
            - yarn workspace partner run build
      artifacts:
        baseDirectory: build
        files:
          - '**/*'

Here is the deployment script:

APPS_TO_RELEASE=("appid1" "appid2" "appid3")
DEPLOYMENT_ENV=prod

JOB_IDS=()

for APP in "${APPS_TO_RELEASE[@]}"; do
  JOB_ID=$(aws amplify start-job --app-id "$APP" --branch-name "$DEPLOYMENT_ENV" --job-type RELEASE --commit-id "$COMMIT_SHA" | jq -r '.jobSummary.jobId')
  echo "Release started for app=$APP env=$DEPLOYMENT_ENV job_id=$JOB_ID"
  JOB_IDS+=("$JOB_ID")
done

Build Result for customer app:

customer

Build Result for ops app (build command is using the customer app one, that is wrong):

ops

Any idea on what was happened? Appreciate your help. Thank you!

asked a year ago76 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions