sanity-io / github-action-sanity

MIT License
57 stars 20 forks source link

Error on backup routine: "can't cd to dataset" #15

Closed felixhagspiel closed 1 year ago

felixhagspiel commented 1 year ago

I have copied your example for the backup routine (thanks for that!). When I manually trigger the action via github, it fails on the Export dataset:

Run sanity-io/github-action-sanity@v0.4-alpha
  with:
    args: dataset export production backups/backup.tar.gz
  env:
    SANITY_AUTH_TOKEN: ***
...
production: 1: cd: can't cd to dataset

this is my yaml file:

name: Backup Routine
on:
  schedule:
    # Runs at 04:00 UTC on the 1st and 17th of every month
    - cron: "0 4 */16 * *"
  workflow_dispatch:
jobs:
  backup-dataset:
    runs-on: ubuntu-18.04
    name: Backup dataset
    steps:
      - uses: actions/checkout@v2
      - name: Export dataset
        uses: sanity-io/github-action-sanity@v0.4-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

any ideas whats wrong? I have added a read only token as secret, and the only thing I have changed is v0.2-alpha -> v0.4-alpha

felixhagspiel commented 1 year ago

I managed to fix it by installing sanity & running the command manually:

name: Backup Routine
on:
  schedule:
    # Runs at 04:00 UTC on the 1st and 17th of every month
    - cron: "0 4 */16 * *"
  workflow_dispatch:
jobs:
  backup-dataset:
    runs-on: ubuntu-18.04
    name: Backup dataset
    steps:
      - uses: actions/checkout@v3
      - name: Export Data
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        run: |
          npm install -g @sanity/cli
          sanity install
          SANITY_AUTH_TOKEN=$SANITY_AUTH_TOKEN sanity dataset export production backups/backup.tar.gz
      - name: Upload backup.tar.gz
        uses: actions/upload-artifact@v3
        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