ambientlight/amplify-cli-action

Error on configure command

Closed this issue · 2 comments

Hi! Thanks for creating this action, so far it had been perfect for my current workflow (deploy to aws and then to now.sh)

I am getting an error on the configure command. Fortunately , it is not breaking my build, just getting printer on the action log.

Error occured during configuration.
{ Error: ENOENT: no such file or directory, open '/github/workspace/amplify/backend/amplify-meta.json'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:343:35)
    at readJsonFile (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/read-json-file.js:10:35)
    at getResourceOutputs (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/get-resource-outputs.js:7:23)
    at AmplifyToolkit.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/on-category-outputs-change.js:33:72)
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/on-category-outputs-change.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/on-category-outputs-change.js:4:12)
    at AmplifyToolkit.onCategoryOutputsChange [as _onCategoryOutputsChange] (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/on-category-outputs-change.js:18:12)
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/github/workspace/amplify/backend/amplify-meta.json' }
found existing environment prod
- Fetching updates to backend environment: prod from the cloud.
✔ Successfully pulled backend environment prod from the cloud.

This is the workflow setup i'm using:

name: Deploy to production

on:
  push:
    branches:
      - master

jobs:
  validate:
    name: ✅ Validate application source (lint, test and build)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v1
      - name: Install dependencies
        run: yarn install
      - name: Run validations
        run: yarn validate

  deploy_aws:
    name: 🚀 Deploy to AWS
    runs-on: ubuntu-latest
    needs: [validate]
    steps:
      - name: Checkout repository
        uses: actions/checkout@v1
      - name: Configure amplify
        uses: ambientlight/amplify-cli-action@v0.1.1
        with:
          amplify_command: configure
          amplify_env: prod
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: us-east-1
      - name: Push resources
        uses: ambientlight/amplify-cli-action@v0.1.1
        with:
          amplify_command: push
          amplify_env: prod
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: us-east-1

  deploy_now:
    name: 🚀 Deploy to Now.sh
    runs-on: ubuntu-latest
    needs: [deploy_aws]
    steps:
      - name: Checkout repository
        uses: actions/checkout@v1
      - name: Deploy
        uses: amondnet/now-deployment@v1
        with:
          zeit-token: ${{ secrets.NOW_TOKEN }}
          github-token: ${{ secrets.GITHUB_TOKEN }}

@iamkevinwolf: thanks a lot for trying it out.

reproduced the behavior you are experiencing.
Turns out amplify configure fails if amplify-meta.json is not committed(which is correct), not sure this is designated behavior or a bug on amplify side.

the amplify env pull succeeds (as of 3.17.0) even if /amplify/.config/local-aws-info.json is not set (which I wasn't aware of), in which case amplify would fallback to environment variable's defined credential and region, since /amplify/.config/project-config.json is committed and action would set /amplify/.config/local-env-info.json with

echo '{"projectPath": "'"$(pwd)"'","defaultEditor":"code","envName":"'$6'"}' > ./amplify/.config/local-env-info.json

so pull works as expected. Which actually renders amplify configure command redundant in this case, I will further test this and release an update

fixed in 0.2.0 release, thanks!