-
Notifications
You must be signed in to change notification settings - Fork 8
85 lines (82 loc) · 2.42 KB
/
dataset-backup.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Backup Routine
on:
workflow_dispatch:
inputs:
dataset:
description: 'Please select the dataset to backup.'
type: choice
options:
- "['global-development']"
- "['global-test']"
- 'all'
required: true
default: 'all'
schedule:
# Runs at 02:00 UTC every sunday
- cron: '0 2 * * 0'
env:
BUILD_ARTIFACT_PATH: ${{ github.workspace }}/backups
jobs:
read-satellites:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
name: Read satellites by choice
run: |
MATRIX=$(cat satellites.json)
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
- uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: failure()
backup-dataset:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
needs: read-satellites
name: Backup dataset
strategy:
matrix:
dataset: ${{ (github.event.inputs.dataset != 'all' && fromJson(github.event.inputs.dataset)) || fromJson(needs.read-satellites.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm 📦
id: install-pnpm
uses: pnpm/[email protected]
with:
version: '8.5.1'
- name: Cache pnpm modules 💾
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- name: Install dependencies 🔧
id: install-dependencies
run: |
pnpm sanityv3 install
- name: Export Data
id: export-data
working-directory: ./sanityv3
env:
SANITY_AUTH_TOKEN: ${{ secrets.SANITY_DEPLOY }}
with:
args: dataset export ${{ matrix.dataset }} backups/${{ matrix.dataset }}.tar.gz
- name: Upload backup.tar.gz
id: upload-backup
uses: actions/upload-artifact@v3
with:
name: backup-tarball
path: backups/${{ matrix.dataset }}.tar.gz
# Fails the workflow if no files are found; defaults to 'warn'
if-no-files-found: error
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: failure()