All Projects → sanity-io → github-action-sanity

sanity-io / github-action-sanity

Licence: MIT license
No description, website, or topics provided.

Programming Languages

HCL
1544 projects
Dockerfile
14818 projects
shell
77523 projects

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-18.04
    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-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

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].