Skip to content

Commit f2c2482

Browse files
committed
Add CI for dashboard
1 parent a1e209b commit f2c2482

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

.ci/clean_cloudflare_cache.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import requests
5+
import sys
6+
7+
files = [
8+
'https://dashboard-dev.terminusdb.com/',
9+
'https://dashboard-dev.terminusdb.com/verify',
10+
'https://dashboard-dev.terminusdb.com/index.html',
11+
'https://dashboard-dev.terminusdb.com/tdb-dashboard.min.js',
12+
'https://dashboard-dev.terminusdb.com/App.css',
13+
'https://dashboard.terminusdb.com/tdb-dashboard.min.js',
14+
'https://dashboard.terminusdb.com/App.css',
15+
'https://dashboard.terminusdb.com/',
16+
'https://dashboard.terminusdb.com/verify',
17+
'https://dashboard.terminusdb.com/index.html',
18+
]
19+
20+
# We don't need to wipe the production cache on every commit
21+
if not sys.argv[1].startswith("refs/tags"):
22+
files = [x for x in files if "dashboard-dev" in x]
23+
24+
headers = {
25+
'X-Auth-Email': os.environ["CLOUDFLARE_EMAIL"],
26+
'X-Auth-Key': os.environ["CLOUDFLARE_API_KEY"],
27+
}
28+
zone = os.environ["CLOUDFLARE_ZONE"]
29+
print(requests.post(f"https://api.cloudflare.com/client/v4/zones/{zone}/purge_cache", json={'files': files}, headers=headers).text)

.ci/install_dependencies.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cd packages/tdb-dashboard
2+
npm i
3+
cd ../tdb-react-layout
4+
npm i
5+
cd ../tdb-react-components
6+
npm i
7+
cd ../react-worker
8+
npm i
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build and release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- v*
8+
pull_request:
9+
10+
jobs:
11+
setup-build-publish-deploy:
12+
name: Setup, Build, Publish, and Deploy
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 16
21+
- run: bash .ci/install_dependencies.sh
22+
- name: Build
23+
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'pull_request' }}
24+
run: |
25+
cd packages/tdb-dashboard
26+
echo '
27+
CONNECTION_TYPE="REMOTE"
28+
TERMINUSDB_SERVER="https://cloud-dev.terminusdb.com/"
29+
FEEDBACK_URL="https://cloud-dev.terminusdb.com/"
30+
REACT_APP_BASE_ROUTER=""
31+
AUTH0_CLIENT_ID="s6iYFJzoSedUHGUUaRYCGGWXWEPHkd02"
32+
AUTH0_DOMAIN="signup-dev.terminusdb.com"
33+
AUDIENCE="https://terminuscloud/users"
34+
' > .env
35+
npm run build
36+
- name: Build prod
37+
if: startsWith(github.ref, 'refs/tags/v')
38+
run: |
39+
cd packages/tdb-dashboard
40+
echo '
41+
CONNECTION_TYPE="REMOTE"
42+
TERMINUSDB_SERVER="https://cloud.terminusdb.com/"
43+
FEEDBACK_URL="https://cloud.terminusdb.com/"
44+
REACT_APP_BASE_ROUTER=""
45+
AUTH0_CLIENT_ID="365PsB0AmUmB2odSFwezWkX31BZv6PoH"
46+
AUTH0_DOMAIN="signup.terminusdb.com"
47+
AUDIENCE="https://terminuscloud/users"
48+
' > .env
49+
npm run build
50+
- name: Set up Cloud SDK
51+
uses: google-github-actions/setup-gcloud@v0
52+
with:
53+
project_id: ${{ secrets.GCLOUD_PROJECT }}
54+
service_account_key: ${{ secrets.GCLOUD_SERVICE_ACCOUNT_KEY }}
55+
export_default_credentials: true
56+
# - name: Upload tdb-dashboard dev
57+
# if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
58+
# run: gsutil -h "Cache-Control:public, max-age=60" cp -r packages/tdb-dashboard/dist/* "gs://${{ secrets.GCLOUD_DEV_BUCKET }}/"
59+
# - name: Upload tdb-dashboard prod
60+
# if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
61+
# run: gsutil -h "Cache-Control:public, max-age=60" cp -r packages/tdb-dashboard/dist/* "gs://${{ secrets.GCLOUD_BUCKET }}/"
62+
# - name: Clean cloudflare cache
63+
# if: ${{ github.event_name != 'pull_request' }}
64+
# run: python3 .ci/clean_cloudflare_cache.py ${{ github.ref }}
65+
# env:
66+
# CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
67+
# CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
68+
# CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
69+
70+
build_for_local:
71+
name: Build local dashboard
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v2
76+
- name: Use Node.js ${{ matrix.node-version }}
77+
uses: actions/setup-node@v2
78+
with:
79+
node-version: 16
80+
- run: bash .ci/install_dependencies.sh
81+
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/v') }}
82+
run: |
83+
cd packages/tdb-dashboard
84+
echo '
85+
CONNECTION_TYPE="LOCAL"
86+
TERMINUSDB_SERVER=http://127.0.0.1:6363/
87+
TERMINUSDB_KEY=root
88+
FEEDBACK_URL="https://cloud.terminusdb.com/"
89+
BASE_URL="dashboard"
90+
' > .env
91+
npm run build
92+
cd dist
93+
tar caf release.tar.gz *
94+
95+
- name: Create Release
96+
if: startsWith(github.ref, 'refs/tags/v')
97+
uses: ncipollo/[email protected]
98+
with:
99+
artifacts: packages/tdb-dashboard/dist/release.tar.gz

0 commit comments

Comments
 (0)