Skip to content

Deploy Sanity Suite #80

Deploy Sanity Suite

Deploy Sanity Suite #80

name: Deploy Sanity Suite
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: What sanity suite environment to deploy (pre-release checks done on staging)
required: true
options:
- production
- staging
permissions:
id-token: write # allows the JWT to be requested from GitHub's OIDC provider
contents: read # This is required for actions/checkout
env:
NODE_OPTIONS: '--no-warnings'
jobs:
deploy-tag:
name: Deploy Sanity Suite
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_PROD_ACCOUNT_ID }}:role/${{ secrets.AWS_PROD_S3_SYNC_ROLE }}
aws-region: us-east-1
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
env:
HUSKY: 0
run: |
npm run setup:ci
- name: Build staging artifacts
if: inputs.environment == 'staging'
env:
WRITE_KEY: ${{ secrets.SANITY_SUITE_WRITE_KEY }}
FEATURE_PRELOAD_BUFFER_WRITE_KEY: ${{ secrets.SANITY_SUITE_FEATURE_PRELOAD_BUFFER_WRITE_KEY }}
FEATURE_EVENT_FILTERING_WRITE_KEY: ${{ secrets.SANITY_SUITE_FEATURE_EVENT_FILTERING_WRITE_KEY }}
FEATURE_DATA_RESIDENCY_WRITE_KEY: ${{ secrets.SANITY_SUITE_FEATURE_DATA_RESIDENCY_WRITE_KEY }}
DATAPLANE_URL: ${{ secrets.SANITY_SUITE_DATAPLANE_URL }}
CONFIG_SERVER_HOST: ${{ secrets.SANITY_SUITE_CONFIG_SERVER_HOST }}
HUSKY: 0
run: |
npm run build:package
npm run build:sanity:staging
- name: Build production artifacts
if: inputs.environment == 'production'
env:
WRITE_KEY: ${{ secrets.SANITY_SUITE_WRITE_KEY }}
FEATURE_PRELOAD_BUFFER_WRITE_KEY: ${{ secrets.SANITY_SUITE_FEATURE_PRELOAD_BUFFER_WRITE_KEY }}
FEATURE_EVENT_FILTERING_WRITE_KEY: ${{ secrets.SANITY_SUITE_FEATURE_EVENT_FILTERING_WRITE_KEY }}
FEATURE_DATA_RESIDENCY_WRITE_KEY: ${{ secrets.SANITY_SUITE_FEATURE_DATA_RESIDENCY_WRITE_KEY }}
DATAPLANE_URL: ${{ secrets.SANITY_SUITE_DATAPLANE_URL }}
CONFIG_SERVER_HOST: ${{ secrets.SANITY_SUITE_CONFIG_SERVER_HOST }}
HUSKY: 0
run: |
npm run build:package
npm run build:sanity
- name: Sync files to S3
run: |
aws s3 cp packages/sanity-suite/dist/ s3://${{ secrets.AWS_PROD_S3_BUCKET_NAME }}/sanity-suite --recursive --cache-control max-age=3600
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_PROD_CF_DISTRIBUTION_ID }} --paths "/sanity-suite*"