This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.46 KB
/
backup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Backup
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
backup:
name: Backup
runs-on: ubuntu-latest
strategy:
matrix:
dataset: [ "development", "production" ]
steps:
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: set output file
id: env
run: echo "BACKUP_FILE=$(date +%Y-%m-%d)-${{ matrix.dataset}}.tar.gz" >> $GITHUB_ENV
- name: setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: install global dependencies
run: |
npm install --global yarn@latest sanity@dev-preview wrangler@latest
- name: install project dependencies
run: |
yarn install
- name: export dataset
run: |
set -e
SANITY_STUDIO_API_PROJECT_ID="${{ secrets.SANITY_STUDIO_API_PROJECT_ID }}" \
SANITY_AUTH_TOKEN="${{ secrets.SANITY_AUTH_TOKEN }}" \
sanity dataset export "${{ matrix.dataset}}" "${{ env.BACKUP_FILE }}"
working-directory: ./studio
- name: upload backup file
run: |
set -e
CLOUDFLARE_ACCOUNT_ID="${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" \
CLOUDFLARE_API_TOKEN="${{ secrets.CLOUDFLARE_API_TOKEN }}" \
wrangler r2 object put "backups/daniel.heene.io/${{ env.BACKUP_FILE }}" -f ${{ env.BACKUP_FILE }}
working-directory: ./studio