sanity-io / github-action-sanity

MIT License
57 stars 20 forks source link

The `sanity` module is not installed in current project #21

Open pwrstudio opened 11 months ago

pwrstudio commented 11 months ago

Similar to #10

When running the backup action I get the following error:

The `sanity` module is not installed in current project
Project-specific commands not available until you run `npm install`

Error: Command "dataset" 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.

This is the workflow file:

name: Backup Routine
on:
  schedule:
    - cron: '0 4 * * 1'
  workflow_dispatch:
jobs:
  backup-dataset:
    runs-on: ubuntu-latest
    name: Backup dataset
    steps:
      - uses: actions/checkout@v2
      - name: Export dataset
        uses: sanity-io/github-action-sanity@v0.7-alpha
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: dataset export production backups/backup.tar.gz
      - name: Upload backup.tar.gz
        uses: actions/upload-artifact@v2
        with:
          name: backup-tarball
          path: backups/backup.tar.gz
          # Fails the workflow if no files are found; defaults to 'warn'
          if-no-files-found: error

Action is added to the repo of the studio: https://github.com/pwrstudio/sat02-admin

doesnotexist commented 10 months ago

Running npm install or yarn install after checking out your project should fix that, like so:

name: Backup Routine
on:
  schedule:
    - cron: '0 4 * * 1'
  workflow_dispatch:
jobs:
  backup-dataset:
    runs-on: ubuntu-latest
    name: Backup dataset
    steps:
      - uses: actions/checkout@v2
      - run: yarn install
      - name: Export dataset
        uses: sanity-io/github-action-sanity@v0.7-alpha
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: dataset export production backups/backup.tar.gz
      - name: Upload backup.tar.gz
        uses: actions/upload-artifact@v2
        with:
          name: backup-tarball
          path: backups/backup.tar.gz
          # Fails the workflow if no files are found; defaults to 'warn'
          if-no-files-found: error