![](/img/trans.png)
[英]Is there a way to use multiple aws profiles to deploy(update) serverless stack?
[英]How to use github action to deploy a serverless mono repo with multiple packages.json?
I'm trying to deploy micro services that are part of a mono repo, for this I'm using github actions but I'm having an issue related to the plugins in the package.json files. 這是我的項目的結構:
--repo
---package.json
---resources
----package.json
---services
----Service A
-----package.json
----Service B
-----package.json
首先,我正在嘗試部署基本上創建 S3 存儲桶、cognito 用戶池等的資源文件夾......我已經添加了名為“serverless-cognito-add-custom-attributes”的插件作為這個項目的一部分,這個插件僅存在於“資源”文件夾內的 package.json 上。
嘗試從 github 操作部署時出現此錯誤:
未找到無服務器插件“serverless-cognito-add-custom-attributes”。 確保它已安裝並列在無服務器配置文件的“插件”部分。
這是我在 github 操作中使用的 .yml 文件:
name: Deploy Resources to Dev
on:
push:
branches:
- dev
tags:
- RC-*
paths:
- './resources'
jobs:
InstallActions:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Node
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Install NPM Global Packages
run: |
npm install --global
npm install "./resources" --global
- name: Serverless Deploy
uses: serverless/github-action@master
with:
args: deploy --stage dev --config "./resources/serverless.yml"
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_DEV}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}
當 above.yml 文件運行時,我可以在控制台上看到:
+ ----@1.0.0
added 1 package in 2.935s
+ resources@1.0.0
added 3 packages from 3 contributors in 0.654s
出於某種原因,似乎
uses: serverless/github-action@master
從子文件夾安裝時無法找到軟件包,但手動執行所有操作似乎工作正常:
name: Deploy Resources to Dev
on:
push:
branches:
- dev
tags:
- RC-*
paths:
- './resources'
jobs:
Deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Node
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Install Serverless Framework
run: npm install -g serverless
- name: Serverless Authentication
run: sls config credentials --provider aws --key ${{secrets.AWS_ACCESS_KEY_DEV}} --secret ${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}
- name: Install NPM dependencies
run: |
npm install
npm install "./resources"
- name: Deploy to AWS
run: serverless deploy -v -s dev
working-directory: "./resources"
我有這個問題大約 17 個小時,然后決定 go 全部手動而不是使用 package serverless/github-action@master
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.