-
Notifications
You must be signed in to change notification settings - Fork 4
180 lines (148 loc) · 5.87 KB
/
build-offline.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build Offline-Binocular
on:
push:
branches:
- "main"
- "develop"
# - "feature/225" #For testing
schedule:
- cron: '30 3 * * 1' # At 03:30 on Monday, https://crontab.guru/#30_3_*_*_1
workflow_dispatch:
inputs:
databaseImage:
description: "Base image to build database from"
default: "ghcr.io/inso-tuwien/binocular-database"
databaseTag:
description: "Base tag to build database from"
default: "latest"
env:
REGISTRY: ghcr.io
ARANGO_VERSION: 3.11.3
IMAGE_NAMESPACE: "ghcr.io/inso-tuwien"
# IMAGE_BASE_NAME: ghcr.io/inso-tuwien/binocular-arangodb_3.11.3
jobs:
build:
runs-on: ubuntu-latest
services:
arangodb:
# image: arangodb:3.11
# image: ghcr.io/inso-tuwien/binocular-database:arangodb_3.11.3-no_volumes
image: ${{ github.event.inputs.databaseImage || 'ghcr.io/inso-tuwien/binocular-database' }}:${{ github.event.inputs.databaseTag || 'latest' }}"
options: --name "arangodb_svc"
ports:
- 8529:8529
env:
ARANGO_ROOT_PASSWORD: openSesame
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setting env variables
id: docker_setup
uses: ./.github/actions/docker-env/
with:
image_name: binocular-database
- name: Debug echo env variables
run: |
echo "########## Docker Tags ##########"
echo ${{ steps.docker_setup.outputs.docker_image_name }}:${{ steps.docker_setup.outputs.docker_image_tag }}
echo ${{ steps.docker_setup.outputs.docker_image_name }}:${{ github.run_id }}
echo ${{ steps.docker_setup.outputs.docker_image_name }}:latest
echo "########## env ##########"
echo NODE_VERSION: ${{ steps.docker_setup.outputs.nvmrc_node_version }}
echo "########## workflow ##########"
echo databaseImage: ${{ inputs.databaseImage }}
echo databaseTag: ${{ inputs.databaseTag }}
- name: Set .pupilrc variables
uses: microsoft/variable-substitution@v1
with:
files: .binocularrc_ci
env:
github.auth.token: ${{ secrets.GITHUB_TOKEN }}
- name: Rename binocularrc
run: mv .binocularrc_ci .binocularrc
- name: Set node version
uses: actions/setup-node@v3
with:
node-version: ${{ steps.docker_setup.outputs.nvmrc_node_version }}
cache: npm
cache-dependency-path: ./package-lock.json
# Source: https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Install tsx
run: npm i tsx -g
- name: Run binocular
run: DEBUG=idx*,importer*,git*,db* tsx ./binocular-backend/binocular.ts run --no-server --no-frontend --export .
- name: Build
env:
NODE_OPTIONS: --max_old_space_size=4096
run: npm run build:offline
- name: Publish artifact
uses: actions/upload-artifact@v3
with:
name: binocular_ui
path: |
./dist/
./ui/db_export
- name: docker commit
run: |
echo ${{ steps.docker_setup.outputs.docker_image_name }}:${{ steps.docker_setup.outputs.docker_image_tag }}
docker commit arangodb_svc ${{ steps.docker_setup.outputs.docker_image_name }}:${{ steps.docker_setup.outputs.docker_image_tag }}
- name: docker images
run: docker images
- name: Init Docker
uses: ./.github/actions/docker-setup
with:
registry_url: ${{ env.REGISTRY }}
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
docker push ${{ steps.docker_setup.outputs.docker_image_name }}:${{ steps.docker_setup.outputs.docker_image_tag }}
#
docker tag ${{ steps.docker_setup.outputs.docker_image_name }}:${{ steps.docker_setup.outputs.docker_image_tag }} ${{ steps.docker_setup.outputs.docker_image_name }}:${{ github.run_id }}
docker push ${{ steps.docker_setup.outputs.docker_image_name }}:${{ github.run_id }}
#
docker tag ${{ steps.docker_setup.outputs.docker_image_name }}:${{ steps.docker_setup.outputs.docker_image_tag }} ${{ steps.docker_setup.outputs.docker_image_name }}:latest
docker push ${{ steps.docker_setup.outputs.docker_image_name }}:latest
deploy:
runs-on: ubuntu-latest
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Download Artifact from previous job
uses: actions/download-artifact@v3
with:
name: binocular_ui
path: artifact/
- name: Display structure of downloaded files
run: |
echo "url:" ${{ env.url }}
echo "page_url:" ${{ steps.deployment.outputs.page_url }}
ls -l artifact/dist/
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: 'artifact/dist/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2