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

Deploying from a subdirectory

Open bernier opened this issue 2 years ago • 3 comments

Hi,

I would like to have the following project structure but I couldn't make it work with the v2, wondering if it's now supported.

.github
... workflows
backend
... serverless.yml
... all other backend files
frontend
... frontend files

Basically, it doesn't seem possible to define a working directory for the serverless app. This is what I'm using for the frontend directory in my pipeline.yaml, I would like to do something similar for the backend directory.

    - name: Building Frontend
      run: npm run build
      working-directory: ${{ env.working-directory-frontend }}

    - name: Deploy to S3
      uses: jakejarvis/s3-sync-action@master
      with:
        args: --acl public-read --follow-symlinks --delete
      env:
        AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AWS_REGION: 'us-west-2'
        SOURCE_DIR: "frontend/dist" 

Thanks!

bernier avatar Mar 16 '22 23:03 bernier

It looks like the docker image doesn't use working-directory.

tibbe avatar Apr 29 '22 11:04 tibbe

Any plan to add this in a future release? This is a huge drawback for me to continue using GitHub actions, pretty sure it's the same for many others who will prefer to use Jenkins or similar.

bernier avatar May 11 '22 15:05 bernier

Try this:

  args: -c "cd ./<your-dir> && serverless deploy"
  entrypoint: /bin/sh

from https://github.com/serverless/github-action/issues/53#issuecomment-1059839383

DavideViolante avatar May 31 '22 08:05 DavideViolante

args: -c "cd ./ && serverless deploy" entrypoint: /bin/sh

This worked well for me. While a formal working_directory option might be slightly cleaner, this issue can probably be closed.

andenacitelli avatar Apr 14 '23 17:04 andenacitelli