Skip to content
upload-cloud

GitHub Action

GitHub Action for Sanity.io

v0.6-alpha Latest version

GitHub Action for Sanity.io

upload-cloud

GitHub Action for Sanity.io

Wraps the Sanity.io to enable common commands

Installation

Copy and paste the following snippet into your .yml file.

              

- name: GitHub Action for Sanity.io

uses: sanity-io/github-action-sanity@v0.6-alpha

Learn more about this action in sanity-io/github-action-sanity

Choose a version

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/github-action-sanity@v0.7-alpha
        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/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

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.