amplify-cli-action
amplify-cli-action copied to clipboard
Bring back build_command support
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: will try to give you an answer this weekend, thanks
@ambientlight thanks for answering i will wait for response thanks.
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?
@ambientlight
- name: Install node packages
run: |
yarn install
uses: ambientlight/[email protected]
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 ?
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
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/[email protected]
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?
@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
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
@juunone: I am sorry for the confusion, build_command was removed as the configure command changed in https://github.com/ambientlight/amplify-cli-action/commit/86d8412c2a97c31bdfa0867d731d82802ac24806#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
@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/[email protected]
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/[email protected]
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?
@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.
@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!