Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back build_command support #11

Open
juunone opened this issue Jul 3, 2020 · 12 comments
Open

Bring back build_command support #11

juunone opened this issue Jul 3, 2020 · 12 comments
Labels
enhancement New feature or request

Comments

@juunone
Copy link

juunone commented Jul 3, 2020

hi i have question for use this amplify action
i change to build command to build_command: 'yarn build:dev' like this.
i have multiple build scripts in package.json

  • yarn build
  • yarn build:dev
  • yarn build:prod

it has each have other build scripts
and i want to publish with yarn:dev script but when i try action
it only use yarn build..
how do i. change build_command ? not only yarn build

second i try to project_dir
amplify and amplify_rnd
i have configure and publish with project_dir: 'amplify_rnd'
but it only look amplify
is am i wrong with use project_dir?
amplfiy_rnd have proejct-config.json and "BuildCommand": "yarn build:rnd"

i will wait for answer
thanks.

@juunone juunone changed the title Build command fail Multiple build command fail Jul 3, 2020
@ambientlight
Copy link
Owner

@juunone: will try to give you an answer this weekend, thanks

@juunone
Copy link
Author

juunone commented Jul 3, 2020

@ambientlight thanks for answering
i will wait for response
thanks.

@ambientlight
Copy link
Owner

ambientlight commented Jul 5, 2020

how do i. change build_command ? not only yarn build

You can use just a bare bash script inside github actions like, add additional step like:

- name: 'Build the code'
        run: |
          yarn build
          yarn build:dev
          yarn build:prod
          // and then either run publish directly, or use another step from `amplify_cli_actions` 
          amplify publish

second i try to project_dir
amplify and amplify_rnd
i have configure and publish with project_dir: 'amplify_rnd'
but it only look amplify
is am i wrong with use project_dir?

Hm, how did you configure here?

@juunone
Copy link
Author

juunone commented Jul 6, 2020

@ambientlight

- name: Install node packages
      run: |
        yarn install     
uses: ambientlight/amplify-cli-action@0.2.1
      with:
        amplify_cli_version: '3.17.0'
        amplify_env: rnd
        amplify_command: publish
        amplify_arguments: '-c'
        build_command: 'yarn build:dev'

i use like this.
with amplify-cli-action but when i build with build_command is only build with yarn build not yarn build:dev
how do i change build_command ?

@ambientlight
Copy link
Owner

ambientlight commented Jul 8, 2020

how do i change build_command ?

can you can try is to rename your commands and then chaining them, inside build_command change yarn build:dev to yarn build_dev && yarn build_prod

@juunone
Copy link
Author

juunone commented Jul 10, 2020

package.json

"build": "PUBLIC_URL=https://www.test.net react-app-rewired build",
"build_rnd": "npm rebuild node-sass && PUBLIC_URL=https://rnd.test.net GENERATE_SOURCEMAP=false NODE_OPTIONS=--max_old_space_size=8192 node_modules/.bin/env-cmd -f .env.development react-app-rewired build",
"build:dev": "npm rebuild node-sass && PUBLIC_URL=https://dev.test.net GENERATE_SOURCEMAP=false NODE_OPTIONS=--max_old_space_size=8192 node_modules/.bin/env-cmd -f .env.development react-app-rewired build",
"build:stg": "npm rebuild node-sass && PUBLIC_URL=https://stg.test.net GENERATE_SOURCEMAP=false NODE_OPTIONS=--max_old_space_size=8192 node_modules/.bin/env-cmd -f .env.development react-app-rewired build",

yml

- name: Build and amplify cli publish to cloud front to prod
      if: contains(github.ref, 'github-action-deploy') 
      uses: ambientlight/amplify-cli-action@0.2.1
      with:
        amplify_cli_version: '3.17.0'
        amplify_env: rnd
        amplify_command: publish
        amplify_arguments: '-c'
        build_command: 'yarn build:rnd'

project-config.json

{
  "projectName": "test",
  "javascript": {
    "framework": "react",
    "config": {
      "SourceDir": "src",
      "DistributionDir": "build",
      "BuildCommand": "yarn build",
      "StartCommand": "yarn start"
    }
  },
  "providers": ["awscloudformation"],
  "frontend": "javascript",
  "version": "3.0"
}

sorry for my question detail. explain more detail to you
i have three each scripts and amplify env.
than i want to deploy each env with script.

i think build_command is not overwrite in project-config.json BuildCommand.
i want to change build script in project-config.json with env-cmd like this ./.env.production yarn build:dev
when i use project_dir it can be split each project-config.json?

@ambientlight
Copy link
Owner

@juunone: If I understood your setup, you want to trigger conditional build command, that is build:dev for dev stage, build:prod for prod stage with amplify project-config.json setup accordingly, this is not on amplify-cli-action side, you may repost this to amplify-cli to seek help there

@juunone
Copy link
Author

juunone commented Jul 16, 2020

is amplify-cli-action build_command only support package.json script with yarn build command?
it's just run only yarn build when i build_command yarn build:dev or yarn build:prod

@ambientlight
Copy link
Owner

ambientlight commented Jul 16, 2020

@juunone: I am sorry for the confusion, build_command was removed as the configure command changed in 86d8412#diff-b958f585a04af5ee2087610ea7180f34

amplify/.config/project-config.json committed will be used by this action (rather then rewritten in amplify configure in first version of this action)
It was still left out in action.yaml so that the steps won't fail after action get updated. (I will update the README to remove build_command step to alliviate the confusion)

So, to reiterate, build_command is no longer managed by this action, if you find your local machine behavior different from whats happening here in CI, this needs to be further investigated but likely it is not on this action side

@juunone
Copy link
Author

juunone commented Jul 17, 2020

@ambientlight i understand it. thanks
because i used build_command and than i think it overwrite in project-config.json's BuildCommand
but it does not.
github action CI is well building in with project-config.json

than you know want i want help things.
i want to conditional build. like this

if: contains(github.ref, 'develop') 
      uses: ambientlight/amplify-cli-action@0.2.1
      with:
        amplify_cli_version: '3.17.0'
        amplify_env: dev
        amplify_command: publish
        amplify_arguments: '-c'
        build_command: 'yarn build:dev'
if: contains(github.ref, 'stg') 
      uses: ambientlight/amplify-cli-action@0.2.1
      with:
        amplify_cli_version: '3.17.0'
        amplify_env: stg
        amplify_command: publish
        amplify_arguments: '-c'
        build_command: 'yarn build:stg'

how do i build with multiple command?

@ambientlight ambientlight added the enhancement New feature or request label Jul 17, 2020
@ambientlight
Copy link
Owner

@juunone: you need to override project-config.json youself for now. You can use something like jq, or sed to replace the build command.

I think overriding project-config.json build_command is a valid usecase, so I'll mark it as a feature request and hopefully will bring back the support for it soon. Thanks.

@juunone
Copy link
Author

juunone commented Jul 17, 2020

@ambientlight yes please~!
it's really useful to overriding project-config.json build_command
because i have multi jobs in yml and that's jobs have each branch and build scripts

thanks for my long question for answer and i will wait for feature will bring back to soon
thank you!

@ambientlight ambientlight changed the title Multiple build command fail Bring back build_command support Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants