sanity-io / github-action-sanity

MIT License
57 stars 20 forks source link

SANITY_STUDIO_CONFIG_PATH not updating active directory with remote #27

Open smoliver opened 4 days ago

smoliver commented 4 days ago

Describe the bug

When working in a mono-repo and using the Action via the github url, setting SANITY_STUDIO_CONFIG_PATH to a path with a sanity config still fails with the error:

Error: Command "deploy" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "sanity"
is installed as a dependency.
    at CommandRunner.runCommand (/usr/local/share/.config/yarn/global/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:71133:13)
    at Object.runCli (/usr/local/share/.config/yarn/global/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:71531:38)

To Reproduce

Folder structure

Main 
├ -.github
⎟  ├ -workflows
⎟  
├ -cms
⎟  ├ -node_modules
⎟  ├ -package.json
⎟  ├ -sanity.config.ts
⎟  ├ -...
⎟
├ -Webapp
├ -...

workflow

name: Deploy Sanity
on:
  push:
    branches: [master]
  workflow_dispatch:
jobs:
  sanity-deploy:
    environment: sanity
    runs-on: ubuntu-latest
    name: Deploy Sanity
    steps:
      - uses: actions/checkout@v2
      - uses: sanity-io/github-action-sanity@v0.7-alpha 
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
          SANITY_STUDIO_CONFIG_PATH: ${{ vars.SANITY_STUDIO_CONFIG_PATH }}
        with:
          args: deploy

However, it works if the Action is copied locally:

name: Deploy Sanity
on:
  push:
    branches: [master]
  workflow_dispatch:
jobs:
  sanity-deploy:
    environment: sanity
    runs-on: ubuntu-latest
    name: Deploy Sanity
    steps:
      - uses: actions/checkout@v2
      - name: Install Sanity to CMS
        working-directory: ./cms
        run: npm i
      - uses: ./.github/github-action-sanity-main
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
          SANITY_STUDIO_CONFIG_PATH: ${{ vars.SANITY_STUDIO_CONFIG_PATH }}
        with:
          args: deploy