Automatic Sanity Studio Deploy

#GitHub Actions

The Setup

To make this work, you'll need to create a new API token in Sanity to put in the Github Repository as a Secret:

1.) Go to and find the desired Sanity project.

2.) Select API in the Project Settings.

3.) Under Tokens, create a new token called SANITY_AUTH_TOKEN as a deploy token:

4.) Create the token, copy it. and add it to your GitHub repo in Settings then add the Secret.

5.) Boom! You're all set to add the code to your .github/workflows folder to enable GH Actions.

The Code

name: Build && Deploy Sanity Studio
    branches: [main]
      - "./web/**"
    name: Build & Deploy Sanity Studio
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - name: Setup Node.js environment
        uses: actions/setup-node@v2
          node-version: 12.x
      - name: Install dependencies
        run: |
          cd studio
          npm install
          npm install @sanity/cli
      - name: Deploy Sanity Studio
        run: |
          set -e
          cd studio
          SANITY_AUTH_TOKEN="${{ secrets.SANITY_AUTH_TOKEN }}" npx sanity deploy