github-action
github-action copied to clipboard
Support for multiple serverless.yml files
I have a monorepo which holds three different Serverless projects. When deploying manually I can simply cd
in to each directory and run sls deploy
.
When using the GitHub workflow, is there a way to specify which directory to use as the "base" directory?
I tried using the working-directory
property offered by Github Workflow, but that property can not be used with Docker-based actions.
@morficus same scenario here :)
@morficus any workaround?
@morficus @lfreneda I have a similar issue, unfortunately for the time being i had to resort to using npx serverless deploy with github's working-directory property
- name: Deploy Foo Stack For Dev
run: npx serverless deploy
working-directory: ./packages/foo
Here is my solution to deploy different serverless.yml based on which branch I am running the action on:
- name: Setup serverless prod
if: github.ref == 'refs/heads/master'
run: mv serverless.prod.yml serverless.yml
- name: Setup serverless dev
if: github.ref == 'refs/heads/dev'
run: mv serverless.dev.yml serverless.yml
- name: Deploy dev
if: github.ref == 'refs/heads/dev'
uses: serverless/github-action@master
with:
args: deploy --stage dev
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Deploy prod
if: github.ref == 'refs/heads/master'
uses: serverless/github-action@master
with:
args: deploy --stage prod
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Hope this helps someone!
waiting for a solution to the problem ☹️
Any updates on this?
You can execure deploy multiple times in same file, each time with different serverless config file
Dev
- name: serverless deploy dev
uses: serverless/github-action@master
with:
args: deploy --config serverless_dev.yml
env:
# SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
# or if using AWS credentials directly
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Prod
- name: serverless deploy prod
uses: serverless/github-action@master
with:
args: deploy --config serverless_prod.yml
env:
# SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
# or if using AWS credentials directly
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}