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!

質問済み 1年前81ビュー
回答なし

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ