Skip to content

Create project copy #59

Create project copy

Create project copy #59

Workflow file for this run

name: Upload data to sanity project
on:
workflow_dispatch:
inputs:
sanity-project-id:
required: true
type: string
sanity-project-dataset:
required: true
type: string
vercel-project-name:
required: true
type: string
vercel-project-id:
required: true
type: string
jobs:
upload-data:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_SANITY_PROJECT_ID: ${{ inputs.sanity-project-id }}
NEXT_PUBLIC_SANITY_DATASET: ${{ inputs.sanity-project-dataset }}
name: Upload data
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Export dataset
run: |
SANITY_AUTH_TOKEN="${{ secrets.SANITY_AUTH_TOKEN }}" \
npx sanity dataset import \
prod-copy.tar.gz production
# curls commands should be run after dataset is uploaded
# to make sure initial production deployment has correct data
- name: Curl command to add vercel deploy hook to sanity
run: |
curl -X POST "https://api.sanity.io/v2021-10-04/hooks/projects/${{ inputs.sanity-project-id }}" \
-H "Authorization: Bearer ${{ secrets.SANITY_AUTH_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"type":"document",
"name":"Sanity Studio",
"url": "https://${{ inputs.vercel-project-name }}.vercel.app/api/sanity-deploy",
"httpMethod":"POST",
"apiVersion":"v2021-03-25",
"includeDrafts":false,
"dataset":"*",
"rule": {
"on": ["create", "update", "delete"]
},
"headers": {
"Authorization": "Bearer ${{ secrets.VERCEL_PERSONAL_AUTH_TOKEN }}"
}
}'
- name: Curl command to triger vercel initial deployment
run: |
curl -X POST "https://api.vercel.com/v13/deployments?teamId=${{ secrets.VERCEL_FR_TEAM_ID }}" \
-H "Authorization: Bearer ${{ secrets.VERCEL_PERSONAL_AUTH_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"name": "${{ inputs.vercel-project-name }}",
"project": "${{ inputs.vercel-project-id }}",
"target": "production",
"gitSource": {
"repoId": "${{ secrets.TEAM_GITHUB_REPO_ID }}",
"ref": "${{ secrets.TEAM_GITHUB_REPO_PRODUCTION_BRANCH }}",
"type": "${{ secrets.REPO_TYPE }}"
}
}'