github-action icon indicating copy to clipboard operation
github-action copied to clipboard

Support for multiple serverless.yml files

Open morficus opened this issue 5 years ago • 7 comments

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 avatar Jan 30 '20 04:01 morficus

@morficus same scenario here :)

lfreneda avatar Mar 11 '20 19:03 lfreneda

@morficus any workaround?

lfreneda avatar Mar 11 '20 19:03 lfreneda

@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

bobbysoar avatar Mar 12 '20 08:03 bobbysoar

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!

reganjohnson avatar Apr 05 '20 06:04 reganjohnson

waiting for a solution to the problem ☹️

ghost avatar Apr 08 '21 09:04 ghost

Any updates on this?

leevi978 avatar May 14 '21 11:05 leevi978

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 }}

marayshi avatar Dec 06 '21 08:12 marayshi