serverless / github-action

:zap::octocat: A Github Action for deploying with the Serverless Framework
Apache License 2.0
658 stars 173 forks source link

Support for multiple serverless.yml files #20

Open morficus opened 4 years ago

morficus commented 4 years ago

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.

lfreneda commented 4 years ago

@morficus same scenario here :)

lfreneda commented 4 years ago

@morficus any workaround?

bobbysoar commented 4 years ago

@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

reganjohnson commented 4 years ago

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!

ghost commented 3 years ago

waiting for a solution to the problem ☹️

leevi978 commented 3 years ago

Any updates on this?

marayshi commented 2 years ago

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