我正在尝试通过github动作进行放大的无头初始化,但是看来该初始化正在/home/runner/.aws/credentials中寻找凭证,而不是使用我通过env提供的凭证。我误解了错误吗?
Github操作:
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up AWS Amplify
run: sudo npm install -g @aws-amplify/cli --unsafe-perm=true
- name: Amplify headless init
run: sh ./headless_init_env.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Amplify headless publish
run: sh ./amplify/deployment/headless_publish.sh
headless_publish.sh:
#!/bin/bash
set -e
IFS='|'
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"accessKeyId\":\"${AWS_ACCESS_KEY_ID}\",\
\"secretAccessKey\":\"${AWS_SECRET_ACCESS_KEY}\",\
\"region\":\"us-east-2\"\
}"
AWSFRONTENDCONFIG="{\
\"SourceDir\": \"src\",\
\"DistributionDir\": \"dist\",\
\"BuildCommand\": \"npm run build\",\
\"StartCommand\": \"npm run serve\"\
}"
AMPLIFY="{\
\"projectName\":\"character-corner\",\
\"envName\":\"prod\",\
\"defaultEditor\":\"code\"\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"
FRONTEND="{\
\"framework\":\"vue\",\
\"config\":$AWSFRONTENDCONFIG\
}"
amplify init \
--amplify $AMPLIFY \
--providers $PROVIDERS \
--frontend $FRONTEND \
--yes
但是我遇到了这个错误:
- Initializing your environment: prod
✖ There was an error initializing your environment.
init failed
Error: ENOENT: no such file or directory, open '/home/runner/.aws/credentials'
at Object.openSync (fs.js:440:3)
at Proxy.readFileSync (fs.js:342:35)
at Object.readFileSync (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/util.js:95:26)
at IniLoader.parseFile (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:6:47)
at IniLoader.loadFrom (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:56:30)
at Config.region (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/node_loader.js:100:36)
at Config.set (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/config.js:507:39)
at Config.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/config.js:342:12)
at Config.each (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/util.js:507:32)
at new Config (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/config.js:341:19) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/runner/.aws/credentials'
}
##[error]Process completed with exit code 1.
AWSCLOUDFORMATIONCONFIG似乎正在绕过提供的凭据,并尝试在不存在的文件中设置带有凭据的环境。
我手动触摸了/home/runner/.aws/credentials和配置文件,脚本进行了,但是一切都失败了。我感觉这是一个禁忌。
ResourceNotReady: Resource is not in the state stackUpdateComplete
at constructor.setError (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/resource_waiter.js:182:47)
at Request.CHECK_ACCEPTORS (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/resource_waiter.js:44:12)
at Request.callListeners (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/aws-sdk/lib/request.js:685:12) {
message: 'Resource is not in the state stackUpdateComplete',