forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (61 loc) · 2.79 KB
/
sync-grapher-schema-to-digital-ocean.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
53
54
55
56
57
58
59
60
61
62
63
name: Upload to DO Spaces
on:
push:
branches:
- master
paths:
- "packages/@ourworldindata/grapher/src/schema/**"
jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@master
- uses: ./.github/actions/setup-node-yarn-deps
- uses: ./.github/actions/build-tsc
- uses: hustcer/setup-nu@v3
with:
version: "0.80" # Don't use 0.80 here, as it was a float number and will be convert to 0.8, you can use v0.80/0.80.0 or '0.80'
# Turn all yaml files in the schema directory into json (should only be one)
- run: |
(ls packages/@ourworldindata/grapher/src/schema/*.yaml
| each {|yaml|
open $yaml.name
| to json
| save -f ($yaml.name
| path parse
| upsert extension "json"
| path join) })
shell: nu {0}
# Construct default config objects for all grapher schemas in the schema directory (should only be one)
- run: |
(ls packages/@ourworldindata/grapher/src/schema/grapher-schema.*.json
| each {|json|
node itsJustJavascript/devTools/schema/generate-default-object-from-schema.js $json.name
| save -f ($json.name
| path parse
| upsert stem ($json.name
| path parse
| get stem
| str replace 'grapher-schema' 'grapher-schema.default')
| path join) })
shell: nu {0}
# Get all files in the schema directory that end with digits.json or digits.yaml and
# copy them to a file called .latest.json or .latest.yaml
- run: |
( ls packages/@ourworldindata/grapher/src/schema/*
| where name =~ '\d+.(json|yaml)$'
| get name
| each { |it| cp $it ($it | str replace '\d+.(json|yaml)$' 'latest.$1') })
shell: nu {0}
- run: ls packages/@ourworldindata/grapher/src/schema
shell: nu {0}
# Now upload all files in that folder to digital ocean.
- uses: BetaHuhn/do-spaces-action@v2
with:
access_key: ${{ secrets.DO_ACCESS_KEY}}
secret_key: ${{ secrets.DO_SECRET_KEY }}
space_name: owid-public
space_region: nyc3
source: packages/@ourworldindata/grapher/src/schema
out_dir: schemas