GithubHelp home page GithubHelp logo

github-action-sanity's Introduction

GitHub Action for Sanity.io

This Action wraps the Sanity CLI for usage inside workflows.

Usage

Below are two examples of usage. Do you use this GitHub Action for a different purpose? Submit a pull request!

Depending on your use case, you will need to generate a read or write token from your project's management console and then add it as a secret in the Studio GitHub repository. In the examples below, the secret was named SANITY_AUTH_TOKEN.

Studio deployment on push requests

This workflow requires a read token.

name: Deploy Sanity
on:
  push:
    branches: [main]
jobs:
  sanity-deploy:
    runs-on: ubuntu-latest
    name: Deploy Sanity
    steps:
      - uses: actions/checkout@v2
      - uses: sanity-io/[email protected]
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: deploy

Backup routine

Thanks to scheduled events and artifacts, you can set up a simple backup routine.

Backup files will appear as downloadable artifacts in the workflow summary. Keep in mind that artifacts are automatically deleted after a certain period of time (after 90 days for public repositories).

This workflow requires a read token.

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

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

Container images built with this project include third-party materials. See THIRD_PARTY_NOTICE.md for details.

github-action-sanity's People

Contributors

eivindml avatar geball avatar kmelve avatar mornir avatar stipsan avatar zapaiamarce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

github-action-sanity's Issues

This action is broken from v0.3 - command arguments are ignored resulting in errors

This github action does not work at all in v0.3 and v0.4 (at least on ubuntu-latest) because there is an error in the entrypoint. All commands taking arguments are impacted.

When you use args like . dataset export production backup.tar.gz, the command getting executed is only sanity dataset which of course doesn't do anything but complain that the usage is not correct.

The reason is this line in entrypoint.sh:

sh -c "cd $1 && sanity install && SANITY_AUTH_TOKEN=$SANITY_AUTH_TOKEN sanity ${@:2:99}"

The problem is that ${@:2:99} is not compatible with basic shells like /bin/sh. To confirm it, you can create a simpler entrypoint showing what it executes:

sh -c "echo SANITY_AUTH_TOKEN=$SANITY_AUTH_TOKEN sanity ${@:2:99}"

which gives, on my machine:

$ ./entrypoint.sh . dataset export production backup.tar.gz
SANITY_AUTH_TOKEN=REDACTED sanity dataset

In summary : everything after the first command is ignored which breaks all workflows.

A simple fix is to use the shift operator which is standard shell:

#!/bin/bash

set -e

sh -c "cd $1 && sanity install"
shift
sh -c "SANITY_AUTH_TOKEN=$SANITY_AUTH_TOKEN sanity $*"

Another fix is to simply not call sh -c but run the commands directly.

Github deprecated Ubuntu 18.04

I use this package v0.4 and an example from this github repo to make a backup on github. After GitHub deprecated Ubuntu 18.04 my action didn't work. I tried to change Ubuntu on 22 and try to change every package into github action but doesn't work. Does anyone have a similar problem or solution for this problem?

SCRIPT must be provided. `sanity exec <script>`

Using v0.3 to execute sanity script results in "Error: SCRIPT must be provided."

name: Sanity Sync Jobs Routine
on:
  workflow_dispatch:
  # schedule:
  # Every hour between 7-19
  # - cron: '0 7-19 * * *'
jobs:
  sanity-exec:
    runs-on: ubuntu-latest
    name: Sync data
    steps:
      - uses: actions/checkout@v2
      - name: Sync data
        uses: sanity-io/[email protected]
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: studio exec functions/syncJobs.js

Response

Error: SCRIPT must be provided. `sanity exec <script>`
    at execScript (/github/workspace/node_modules/@sanity/core/lib/actions/exec/execScript.js:41:[11](https://github.com/guilty-as/safe-bemanning/runs/8078208168?check_suite_focus=true#step:4:12))
    at Object.action (/github/workspace/node_modules/@sanity/util/lib/lazyRequire.js:14:10)
    at _.runCommand (/usr/local/share/.config/yarn/global/node_modules/@sanity/cli/bin/sanity-cli.js:3608:2242)

Error in dockerfile: REGISTRY_DOMAIN, NPM_TOKEN etc are not set properly

There is a silent error in the dockerfile. It does not prevent the build but it's a bug for anyone relying on the behaviour to set a custom REGISTRY_DOMAIN.

The line in question is:

RUN if [[ -z "$NPM_SCOPE" && -z "$NPM_TOKEN" && -z "$REGISTRY_DOMAIN" ]]; \
    then \
    echo -e "//$REGISTRY_DOMAIN/:_authToken=$NPM_TOKEN\\n$NPM_SCOPE:registry=https://$REGISTRY_DOMAIN/" > .npmrc ; \
    fi

When building, this line fails, so effectively the build args REGISTRY_DOMAIN, NPM_TOKEN and NPM_SCOPE are ignored.

Build logs (cf step 15):

Step 14/17 : ARG REGISTRY_DOMAIN
 ---> Running in 4881[96](https://github.com/hestiia-engineering/ecommerce-backend-sanity/actions/runs/5156608732/jobs/9287830414#step:2:96)cf5011
Removing intermediate container 488196cf5011
 ---> 2eafbc358259
Step 15/17 : RUN if [[ -z "$NPM_SCOPE" && -z "$NPM_TOKEN" && -z "$REGISTRY_DOMAIN" ]];     then     echo -e "//$REGISTRY_DOMAIN/:_authToken=$NPM_TOKEN\\n$NPM_SCOPE:registry=https://$REGISTRY_DOMAIN/" > .npmrc ;     fi
 ---> Running in 79ee42191fbf
/bin/sh: 1: [[: not found
Removing intermediate container 79ee42191fbf
 ---> 38c5e1d5eb88
Step 16/17 : COPY entrypoint.sh /entrypoint.sh
 ---> 9292bab8fc07
Step 17/17 : ENTRYPOINT ["/entrypoint.sh"]
 ---> Running in 696606a6dd73
Removing intermediate container 696606a6dd73
 ---> 4c5ebde6d258
Successfully built 4c5ebde6d258
Successfully tagged ed866e:a4e41192dabf4b21b910df695459aeac

Error: sanity.cli.ts does not contain a project identifier

I am getting the error: "Error: sanity.cli.ts does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API"

To Reproduce

Steps to reproduce the behavior:

  1. Use the export/backup example code but use the latest version 0.7-alpha
  2. Used a read+write token since I was also going to use the sanity dataset import but never got to that point
  3. Received error

Expected behavior

The workflow should succeed

Screenshots

Screenshot 2023-12-15 at 09 03 57

Which versions of Sanity are you using?
v3.21.3

Engine node incompatible with @sanity/[email protected]

This action has been working fine until recently where an exception is thrown:
error @sanity/[email protected]: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.1" error Found incompatible module.

This makes backup routines fail.

Full error log from job:

Build container for action use: '/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile'.
  /usr/bin/docker build -t 48c179:85d3dc338b594963a031b751a7f4fefd -f "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile" "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha"
  Sending build context to Docker daemon  75.78kB
  
  Step 1/13 : FROM node:10-slim
  10-slim: Pulling from library/node
  62deabe7a6db: Pulling fs layer
  f698164f6049: Pulling fs layer
  bc29352cb629: Pulling fs layer
  85e84b4c858f: Pulling fs layer
  ac72e4359589: Pulling fs layer
  85e84b4c858f: Waiting
  ac72e4359589: Waiting
  f698164f6049: Verifying Checksum
  f698164f6049: Download complete
  85e84b4c858f: Verifying Checksum
  85e84b4c858f: Download complete
  bc29352cb629: Verifying Checksum
  bc29352cb629: Download complete
  62deabe7a6db: Verifying Checksum
  62deabe7a6db: Download complete
  ac72e4359589: Verifying Checksum
  ac72e4359589: Download complete
  62deabe7a6db: Pull complete
  f698164f6049: Pull complete
  bc29352cb629: Pull complete
  85e84b4c858f: Pull complete
  ac72e4359589: Pull complete
  Digest: sha256:88932859e3d022d79161b99628c4c2c50e836437455e2d1b1a008d98367b10d6
  Status: Downloaded newer image for node:10-slim
   ---> 6fbcbbb5c603
  Step 2/13 : LABEL version="1.0.0"
   ---> Running in 03e1393c35f1
  Removing intermediate container 03e1393c35f1
   ---> 0cef081dd8bc
  Step 3/13 : LABEL repository="http://github.com/kmelve/actions-sanity-io"
   ---> Running in f7d2e0409ac5
  Removing intermediate container f7d2e0409ac5
   ---> d7d639b7f1f8
  Step 4/13 : LABEL homepage="http://github.com/actions/actions-sanity-io"
   ---> Running in cb55e4b2d99b
  Removing intermediate container cb55e4b2d99b
   ---> 5b33a4d9bf50
  Step 5/13 : LABEL maintainer="Sanity.io <[email protected]>"
   ---> Running in 025403bee9d1
  Removing intermediate container 025403bee9d1
   ---> 2e17738ef7cf
  Step 6/13 : LABEL "com.github.actions.name"="GitHub Action for Sanity.io"
   ---> Running in cb3f3bd19ef4
  Removing intermediate container cb3f3bd19ef4
   ---> 4ee82979bb51
  Step 7/13 : LABEL "com.github.actions.description"="Wraps the Sanity.io to enable common commands."
   ---> Running in 71992c551c45
  Removing intermediate container 71992c551c45
   ---> a44a4095aab3
  Step 8/13 : LABEL "com.github.actions.icon"="upload-cloud"
   ---> Running in a9cae9ad24e4
  Removing intermediate container a9cae9ad24e4
   ---> 1e274a0a4c25
  Step 9/13 : LABEL "com.github.actions.color"="red"
   ---> Running in eeb66ef21b7a
  Removing intermediate container eeb66ef21b7a
   ---> 4f359fb01069
  Step 10/13 : COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
   ---> 0b87c5bc196f
  Step 11/13 : RUN yarn global add @sanity/cli
   ---> Running in 114be94dbe3d
  yarn global v1.22.5
  [1/4] Resolving packages...
  [2/4] Fetching packages...
  error @sanity/[email protected]: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.1"
  error Found incompatible module.
  info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  The command '/bin/sh -c yarn global add @sanity/cli' returned a non-zero code: 1
  Warning: Docker build failed with exit code 1, back off 4.166 seconds before retry.
  /usr/bin/docker build -t 48c179:85d3dc338b594963a031b751a7f4fefd -f "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile" "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha"
  Sending build context to Docker daemon  75.78kB
  
  Step 1/13 : FROM node:10-slim
   ---> 6fbcbbb5c603
  Step 2/13 : LABEL version="1.0.0"
   ---> Using cache
   ---> 0cef081dd8bc
  Step 3/13 : LABEL repository="http://github.com/kmelve/actions-sanity-io"
   ---> Using cache
   ---> d7d639b7f1f8
  Step 4/13 : LABEL homepage="http://github.com/actions/actions-sanity-io"
   ---> Using cache
   ---> 5b33a4d9bf50
  Step 5/13 : LABEL maintainer="Sanity.io <[email protected]>"
   ---> Using cache
   ---> 2e17738ef7cf
  Step 6/13 : LABEL "com.github.actions.name"="GitHub Action for Sanity.io"
   ---> Using cache
   ---> 4ee82979bb51
  Step 7/13 : LABEL "com.github.actions.description"="Wraps the Sanity.io to enable common commands."
   ---> Using cache
   ---> a44a4095aab3
  Step 8/13 : LABEL "com.github.actions.icon"="upload-cloud"
   ---> Using cache
   ---> 1e274a0a4c25
  Step 9/13 : LABEL "com.github.actions.color"="red"
   ---> Using cache
   ---> 4f359fb01069
  Step 10/13 : COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
   ---> Using cache
   ---> 0b87c5bc196f
  Step 11/13 : RUN yarn global add @sanity/cli
   ---> Running in a3ead0fca920
  yarn global v1.22.5
  [1/4] Resolving packages...
  [2/4] Fetching packages...
  error @sanity/[email protected]: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.1"
  error Found incompatible module.
  info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  The command '/bin/sh -c yarn global add @sanity/cli' returned a non-zero code: 1
  Warning: Docker build failed with exit code 1, back off 6.445 seconds before retry.
  /usr/bin/docker build -t 48c179:85d3dc338b594963a031b751a7f4fefd -f "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile" "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha"
  Sending build context to Docker daemon  75.78kB
  
  Step 1/13 : FROM node:10-slim
   ---> 6fbcbbb5c603
  Step 2/13 : LABEL version="1.0.0"
   ---> Using cache
   ---> 0cef081dd8bc
  Step 3/13 : LABEL repository="http://github.com/kmelve/actions-sanity-io"
   ---> Using cache
   ---> d7d639b7f1f8
  Step 4/13 : LABEL homepage="http://github.com/actions/actions-sanity-io"
   ---> Using cache
   ---> 5b33a4d9bf50
  Step 5/13 : LABEL maintainer="Sanity.io <[email protected]>"
   ---> Using cache
   ---> 2e17738ef7cf
  Step 6/13 : LABEL "com.github.actions.name"="GitHub Action for Sanity.io"
   ---> Using cache
   ---> 4ee82979bb51
  Step 7/13 : LABEL "com.github.actions.description"="Wraps the Sanity.io to enable common commands."
   ---> Using cache
   ---> a44a4095aab3
  Step 8/13 : LABEL "com.github.actions.icon"="upload-cloud"
   ---> Using cache
   ---> 1e274a0a4c25
  Step 9/13 : LABEL "com.github.actions.color"="red"
   ---> Using cache
   ---> 4f359fb01069
  Step 10/13 : COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
   ---> Using cache
   ---> 0b87c5bc196f
  Step 11/13 : RUN yarn global add @sanity/cli
   ---> Running in bb7fb5653d16
  yarn global v1.22.5
  [1/4] Resolving packages...
  [2/4] Fetching packages...
  error @sanity/[email protected]: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.1"
  error Found incompatible module.
  info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  The command '/bin/sh -c yarn global add @sanity/cli' returned a non-zero code: 1
Error: Docker build failed with exit code 1

failed to deploy on github action

Summary

I tried to set up a github action to deploy Sanity studio automaitcally but it fails.
It seems like it's about node version, but I am not sure because I am new to github actions and this kinda things.
Can you help me?

What I did

I stored my API token on my sanity studio github repo as a secret.
I added main.yml file in .github/workflows directory.

name: Deploy Sanity
on:
  push:
    branches: [main]
jobs:
  sanity-deploy:
    runs-on: ubuntu-latest
    name: Deploy Sanity
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - name: Install Dependencies
        run: yarn install
      - uses: sanity-io/[email protected]
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: deploy

What happened

When I push a commit on main branch, github action failes.
Here is the entire log of github action after a set up a job phase.

Build container for action use: '/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile'.
  /usr/bin/docker build -t 943[51](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:51)b:95780fdf9b034a66b36719485aca6d60 -f "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile" "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha"
  #0 building with "default" instance using docker driver
  
  #1 [internal] load .dockerignore
  #1 transferring context: 174B done
  #1 DONE 0.0s
  
  #2 [internal] load build definition from Dockerfile
  #2 transferring dockerfile: 632B done
  #2 DONE 0.0s
  
  #3 [auth] library/node:pull token for registry-1.docker.io
  #3 DONE 0.0s
  
  #4 [internal] load metadata for docker.io/library/node:10-slim
  #4 DONE 0.4s
  
  #5 [internal] load build context
  #5 transferring context: 69.12kB done
  #5 DONE 0.0s
  
  #6 [1/4] FROM docker.io/library/node:10-slim@sha256:88932859e3d022d79161b99628c4c2c50e836437455e2d1b1a008d98367b10d6
  #6 resolve docker.io/library/node:10-slim@sha256:88932859e3d022d79161b99628c4c2c50e836437455e2d1b1a008d98367b10d6 done
  #6 sha256:88932859e3d022d79161b99628c4c2c50e836437455e2d1b1a008d98367b10d6 776B / 776B done
  #6 sha256:64c30c91d628d40eb8f772ee1477f78aff820e317e8afbc5160857ee804e4b70 1.37kB / 1.37kB done
  #6 sha256:6fbcbbb5c6032ce4013d4c736ffe54e0764c36fa14315ae54cb51f244e813c52 7.09kB / 7.09kB done
  #6 sha256:62deabe7a6db312ed773ccd640cd7cfbf51c22bf466886345684558f1036e358 17.83MB / 22.53MB 0.2s
  #6 sha256:f698164f6049bead44aeb7590e88d3df323011c20f0cedbff3d86f62e4c9f184 4.17kB / 4.17kB 0.1s done
  #6 sha256:bc29352cb629712e7fbce7227a16b53308b541ef41e19122a04c15646756b176 15.73MB / 21.91MB 0.2s
  #6 sha256:85e84b4c858fae373ccdf48432de781210efb7fd75d9d801be9917577fe6ca09 1.05MB / 2.93MB 0.2s
  #6 sha256:62deabe7a6db312ed773ccd640cd7cfbf51c22bf466886345684558f1036e358 22.53MB / 22.53MB 0.3s done
  #6 sha256:bc29352cb629712e7fbce7227a16b53308b541ef41e19122a04c15646756b176 21.91MB / 21.91MB 0.3s
  #6 sha256:85e84b4c858fae373ccdf48432de781210efb7fd75d9d801be9917577fe6ca09 2.93MB / 2.93MB 0.3s done
  #6 extracting sha256:62deabe7a6db312ed773ccd640cd7cfbf51c22bf466886345684558f1036e358 0.1s
  #6 sha256:bc29352cb629712e7fbce7227a16b53308b541ef41e19122a04c15646756b176 21.91MB / 21.91MB 0.3s done
  #6 sha256:ac72e4359589952a2e38fbe10287d792cbb57f2ec3cd1eb730e9bab685ac9754 295B / 295B 0.4s done
  #6 extracting sha256:62deabe7a6db312ed773ccd640cd7cfbf51c22bf466886345684558f1036e358 1.2s done
  #6 extracting sha256:f698164f6049bead44aeb7590e88d3df323011c20f0cedbff3d86f62e4c9f184 done
  #6 extracting sha256:bc29352cb629712e7fbce7227a16b53308b541ef41e19122a04c15646756b176
  #6 extracting sha256:bc29352cb629712e7fbce7227a16b53308b541ef41e19122a04c15646756b176 1.5s done
  #6 extracting sha256:85e84b4c858fae373ccdf48432de781210efb7fd75d9d801be9917577fe6ca09 0.1s done
  #6 extracting sha256:ac72e4359589952a2e38fbe10287d792cbb57f2ec3cd1eb730e9bab685ac9754 done
  #6 DONE 3.6s
  
  #7 [2/4] COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
  #7 DONE 0.0s
  
  #8 [3/4] RUN yarn global add @sanity/cli
  #8 0.427 yarn global v1.22.5
  #8 0.468 [1/4] Resolving packages...
  #8 1.631 [2/4] Fetching packages...
  #8 5.600 error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.24.1"
  #8 5.609 error Found incompatible module.
  #8 5.609 info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  #8 ERROR: process "/bin/sh -c yarn global add @sanity/cli" did not complete successfully: exit code: 1
  ------
   > [3/4] RUN yarn global add @sanity/cli:
  0.427 yarn global v1.22.5
  0.468 [1/4] Resolving packages...
  1.631 [2/4] Fetching packages...
  5.600 error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.24.1"
  5.609 error Found incompatible module.
  5.609 info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  ------
  Dockerfile:14
  --------------------
    12 |     COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
    13 |     
    14 | >>> RUN yarn global add @sanity/cli
    15 |     
    16 |     COPY entrypoint.sh /entrypoint.sh
  --------------------
  ERROR: failed to solve: process "/bin/sh -c yarn global add @sanity/cli" did not complete successfully: exit code: 1
  Warning: Docker build failed with exit code 1, back off 5.007 seconds before retry.
  /usr/bin/docker build -t 94351b:95780fdf9b034a66b36719485aca6d60 -f "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile" "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha"
  #0 building with "default" instance using docker driver
  
  #1 [internal] load .dockerignore
  #1 transferring context: 174B done
  #1 DONE 0.0s
  
  #2 [internal] load build definition from Dockerfile
  #2 transferring dockerfile: 632B done
  #2 DONE 0.0s
  
  #3 [internal] load metadata for docker.io/library/node:10-slim
  #3 DONE 0.1s
  
  #4 [1/4] FROM docker.io/library/node:10-slim@sha256:88932859e3d022d79161b99628c4c2c50e836437455e2d1b1a008d98367b10d6
  #4 DONE 0.0s
  
  #5 [internal] load build context
  #5 transferring context: 132B done
  #5 DONE 0.0s
  
  #6 [2/4] COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
  #6 CACHED
  
  #7 [3/4] RUN yarn global add @sanity/cli
  #7 0.394 yarn global v1.22.5
  #7 0.437 [1/4] Resolving packages...
  #7 1.330 [2/4] Fetching packages...
  #7 5.044 error [email protected]: The engine "node" is incompatible with this module. Expected version ">=12". Got "10.24.1"
  #7 5.0[53](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:53) error Found incompatible module.
  #7 5.053 info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  #7 ERROR: process "/bin/sh -c yarn global add @sanity/cli" did not complete successfully: exit code: 1
  ------
   > [3/4] RUN yarn global add @sanity/cli:
  0.394 yarn global v1.22.5
  0.437 [1/4] Resolving packages...
  1.330 [2/4] Fetching packages...
  5.044 error [email protected]: The engine "node" is incompatible with this module. Expected version ">=12". Got "10.24.1"
  5.053 error Found incompatible module.
  5.053 info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  ------
  Dockerfile:14
  --------------------
    12 |     COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
    13 |     
    14 | >>> RUN yarn global add @sanity/cli
    15 |     
    16 |     COPY entrypoint.sh /entrypoint.sh
  --------------------
  ERROR: failed to solve: process "/bin/sh -c yarn global add @sanity/cli" did not complete successfully: exit code: 1
  Warning: Docker build failed with exit code 1, back off 1.369 seconds before retry.
  /usr/bin/docker build -t 94351b:95780fdf9b034a66b36719485aca6d60 -f "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha/Dockerfile" "/home/runner/work/_actions/sanity-io/github-action-sanity/v0.1-alpha"
  #0 building with "default" instance using docker driver
  
  #1 [internal] load .dockerignore
  #1 transferring context: 174B done
  #1 DONE 0.0s
  
  #2 [internal] load build definition from Dockerfile
  #2 transferring dockerfile: 632B done
  #2 DONE 0.0s
  
  #3 [internal] load metadata for docker.io/library/node:10-slim
  #3 DONE 0.1s
  
  #4 [1/4] FROM docker.io/library/node:10-slim@sha256:88932859e3d022d79161b99628c4c2c50e8364374[55](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:55)e2d1b1a008d983[67](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:67)b10d6
  #4 DONE 0.0s
  
  #5 [internal] load build context
  #5 transferring context: 132B done
  #5 DONE 0.0s
  
  #6 [2/4] COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
  #6 CACHED
  
  #7 [3/4] RUN yarn global add @sanity/cli
  #7 0.388 yarn global v1.22.5
  #7 0.429 [1/4] Resolving packages...
  #7 1.351 [2/4] Fetching packages...
  #7 5.0[82](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:82) error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.24.1"
  #7 5.091 error Found incompatible module.
  #7 5.092 info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  #7 ERROR: process "/bin/sh -c yarn global add @sanity/cli" did not complete successfully: exit code: 1
  ------
   > [3/4] RUN yarn global add @sanity/cli:
  0.3[88](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:88) yarn global v1.22.5
  0.429 [1/4] Resolving packages...
  1.351 [2/4] Fetching packages...
  5.082 error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.24.1"
  5.0[91](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:91) error Found incompatible module.
  5.0[92](https://github.com/obzva/observatory/actions/runs/6276123206/job/17045103623#step:2:92) info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
  ------
  Dockerfile:14
  --------------------
    12 |     COPY LICENSE README.md THIRD_PARTY_NOTICE.md /
    13 |     
    14 | >>> RUN yarn global add @sanity/cli
    15 |     
    16 |     COPY entrypoint.sh /entrypoint.sh
  --------------------
  ERROR: failed to solve: process "/bin/sh -c yarn global add @sanity/cli" did not complete successfully: exit code: 1
Error: Docker build failed with exit code 1

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

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/[email protected]
  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/[email protected]
        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

Error when running "backup" demo: `Session not found. You may need to login again with sanity login.`

Describe the bug

I get the following message trying to run the backup demonstration in the README:
Error: Unauthorized - Session not found. You may need to login again with sanity login.

I have set SANITY_AUTH_TOKEN in my repository secrets. I have tried using several Sanity API tokens: one with the deploy-studio designation, one developer token and one viewer token. However, they all throw the same error.

According to the docs this message could mean:

    - A temporary issue, please try to run your command again.
    - You have specified an invalid token with the SANITY_AUTH_TOKEN env variable.
    - The session timed out. Try to log out and log in again with the sanity logout and sanity login CLI commands.
    - There was an issue with your logged in user. Try to logout and login again.

I'm confused here because my understanding of deploy tokens is that sanity login shouldn't be required. So, reasons 3 & 4 don't apply when I get that error using a deploy token.

To Reproduce
I copied the code from the "backup" demo in the readme, with a small modification to run the workflow manually instead of on a cron job. Here is the full code of my workflow:

name: "Backup prod CMS"
on:
  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/[email protected]
        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

when using the modul I get "Error: Command "dataset" is not available outside of a Sanity project context."

Hi,
when I use the workflow you published:

jobs:
  backup-dataset:
    runs-on: ubuntu-18.04
    name: Backup dataset
    steps:
      - uses: actions/checkout@v2
      - name: Export dataset
        uses: sanity-io/[email protected]
        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

I get this error on each:
Error: Command "dataset" is not available outside of a Sanity project context.

Error: No files were found with the provided path

I'm getting the following error when my action run.

Error: No files were found with the provided path: backups/backup.tar.gz. No artifacts will be uploaded.

Version: v0.4

Here is my .yml action code (note: I have a monorepo and 'studio' is the folder where Sanity resides):

name: Sanity Dataset Backup
on:
  schedule:
    # Runs at 06:00pm EST everyday
    - cron: '0 18 * * *'
  workflow_dispatch:
jobs:
  backup-dataset:
    runs-on: ubuntu-latest
    name: Backup dataset
    defaults:
      run:
        working-directory: studio
    steps:
      - uses: actions/checkout@v2
      - name: Export dataset
        uses: sanity-io/[email protected]
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: studio 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

Screenshot 2023-02-08 at 1 52 50 PM

The `sanity` module is not installed in current project

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/[email protected]
        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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.