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!

질문됨 일 년 전81회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠