@@ -4,10 +4,14 @@ name: Deploy DSpace
44on :
55 workflow_call :
66 inputs :
7+ DEV_MACHINE :
8+ required : false
9+ type : string
10+ default : ' dev-6'
711 INSTANCE :
812 required : false
913 type : string
10- default : ' 5 '
14+ default : ' 8563 '
1115 IMPORT :
1216 required : false
1317 default : true
2125 inputs :
2226 INSTANCE :
2327 required : true
24- default : ' 5 '
28+ default : ' 8563 '
2529 type : choice
2630 options :
27- - ' *'
28- - ' 5'
29- - ' 8'
31+ - ' 8563'
3032 IMPORT :
3133 required : true
3234 default : true
3537 required : false
3638 default : false
3739 type : boolean
40+ DEV_MACHINE :
41+ required : false
42+ type : string
43+ default : ' dev-6'
3844
3945jobs :
40- deploy-5 :
41- if : inputs.INSTANCE == '*' || inputs.INSTANCE == '5 '
42- runs-on : dspace-dep-1
46+ deploy-3 :
47+ if : inputs.INSTANCE == '*' || inputs.INSTANCE == '8563 '
48+ runs-on : dspace-${{inputs.DEV_MACHINE}}- dep-1
4349 timeout-minutes : 10
4450 env :
45- INSTANCE : ' 5'
46- ENVFILE : /opt/dspace-envs/.env.dspace.dev-5
51+ INSTANCE : ' 8563'
52+ CONFIG_PATH : /opt/dspace-envs/${{inputs.INSTANCE}}
53+ ENVFILE : /opt/dspace-envs/${{inputs.INSTANCE}}/.env
4754 steps :
4855 - uses : actions/checkout@v4
4956
@@ -53,235 +60,52 @@ jobs:
5360 INSTANCE : ${{ env.INSTANCE }}
5461 NAME : dspace-${{ env.INSTANCE }}
5562
56- - name : deploy to dev-5
63+ - name : deploy to ${{inputs.DEV_MACHINE}}
5764 working-directory : build-scripts/run/
5865 run : |
5966 ./start.sh dspace-$INSTANCE
6067 cd ../..
6168 # use customized docker-compose file for the `85` port because the server is exposed with the namespace `repository`
6269 # `/repository/server`
63- docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f /opt/dspace-envs/5/ docker-compose-rest.yml -f /opt/dspace-envs/5 /docker-compose.yml up -d --no-build
70+ docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f $CONFIG_PATH/ docker-compose-rest.yml -f $CONFIG_PATH /docker-compose.yml up -d --no-build
6471
65- deploy-8 :
66- if : inputs.INSTANCE == '*' || inputs.INSTANCE == '8'
67- runs-on : dspace-dep-1
72+ import-3 :
73+ runs-on : dspace-${{ inputs.DEV_MACHINE}}-dep-1
74+ if : inputs.IMPORT
6875 timeout-minutes : 120
76+ needs : deploy-3
6977 env :
70- INSTANCE : ' 8'
71- # 2024/02: this .env replaces ENTRYPOINT to angular
72- # !!!!WARNING!!!!
73- # disable TSL checks = allowing to cooperate with https backend with invalid
74- # certificate
75- ENVFILE : /opt/dspace-envs/.env.dspace.imported.dev-5
78+ INSTANCE : ${{inputs.INSTANCE}}
79+ CONFIG_PATH : /opt/dspace-envs/
7680 steps :
77- - uses : actions/checkout@v4
78-
79- - uses : ./.github/actions/erase-db
80- if : inputs.ERASE_DB
81- with :
82- INSTANCE : ${{ env.INSTANCE }}
83- NAME : dspace-${{ env.INSTANCE }}
84-
85- - name : deploy dspace-import on dev-5
86- working-directory : build-scripts/run/
81+ - name : vanilla import
82+ env :
83+ FNAME : old_dump.sql
8784 run : |
88- ./start.sh dspace-$INSTANCE
89- cd ../..
90- # this is not necessary, since extra.yml doesn't contain any new images that weren't pulled within script above
91- # docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f /opt/dspace-envs/8/extra.yml pull
92- docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f /opt/dspace-envs/8/extra.yml up -d --no-build
93-
94- # this must be here and not in the start.sh, because extra.yml replaces dspace container
95- ## !!!!! please remove this section if you do not want handle server !!!!!!!
85+ export DATADIR=$CONFIG_PATH/${{inputs.INSTANCE}}/dump/$FNAME
86+ export DNAME=dspace${{inputs.INSTANCE}}
87+ export DDBNAME=dspacedb${{inputs.INSTANCE}}
88+
89+ echo "====="
90+ docker stop $DNAME || true
91+
92+ echo "====="
93+ # echo Starting vanilla import DB
94+ docker cp $DATADIR $DDBNAME:/tmp/
95+ # drop + create + import + cleanup
96+ docker exec $DDBNAME /bin/bash -c "dropdb -U dspace -p 10563 dspace && createdb -U dspace -p 10563 --owner=dspace --encoding=UNICODE dspace && psql -p 10563 -U dspace -d dspace -f /tmp/$FNAME && rm /tmp/$FNAME"
97+ echo "====="
98+ docker start $DNAME
99+ sleep 60
100+ docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace database migrate ignored && ./dspace create-administrator -e test@test.edu -f admin -l user -p admin -c en -o dataquest"
101+ echo "====="
102+ # new user will not be accepted unless restarted
103+ docker restart $DNAME
104+ sleep 60
96105 echo "====="
97- echo "installing handle server"
98- docker exec dspace${INSTANCE} apt update
99- docker exec dspace${INSTANCE} apt install host -y
100- echo "installed host from apt"
101- docker exec dspace${INSTANCE} /dspace/bin/make-handle-config
102- echo "made handle config:"
103- docker exec dspace${INSTANCE} cat /dspace/handle-server/config.dct
104- docker exec dspace${INSTANCE} /dspace/bin/start-handle-server
105- echo "started handle server"
106- # this seems to be the easiest solution for now
107- docker restart dockerized-nginx-with-shibboleth-nginx-1
108- /bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://dev-5.pc:8$INSTANCE/repository/server/api)" != "200" ]]; do sleep 5; done'
109-
110-
111- import-8 :
112- runs-on : dspace-dep-1
113- if : inputs.IMPORT
114- needs : deploy-8
115- env :
116- INSTANCE : ' 8'
117- ENVFILE : /opt/dspace-envs/.env.dspace.imported.dev-5
118- steps :
119- - uses : ./.github/actions/import-db
120- with :
121- INSTANCE : ${{ env.INSTANCE }}
122- DATADIR : /opt/dspace-data/clarin-dspace/
123- ASSETSTORE : /opt/dspace-data/clarin-dspace/assetstore/
124- LOGDIR : /log/
125-
126- - name : dspace basic command
127- run : |
128- export DNAME=dspace$INSTANCE
129- docker logs -n 50 $DNAME
130-
131- echo "dspace version:"
132- docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace version"
133-
134- echo "dspace cleanup:"
135- docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace cleanup -v"
136-
137- echo "dspace reindex solr:"
138- docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace index-discovery -b"
139-
140- echo "dspace reindex OAI-PMH:"
141- docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace oai import -c"
142-
143- echo "dspace checker:"
144- docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace checker -v -l"
145106
146107 - name : dspace healthcheck
147108 run : |
148- export DNAME=dspace$INSTANCE
109+ export DNAME=dspace${{inputs. INSTANCE}}
149110 echo "dspace healthcheck:"
150111 docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace healthcheck -v"
151-
152- playwright-after-deploy8 :
153- runs-on : dspace-test-1
154- needs : deploy-8
155- timeout-minutes : 45
156- if : ' !inputs.IMPORT'
157- steps :
158- - name : Checkout Playwright tests
159- uses : actions/checkout@v4
160- with :
161- repository : dataquest-dev/dspace-ui-tests
162- path : dspace-ui-tests
163- token : ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}
164-
165- - name : Checkout main repository
166- uses : actions/checkout@v4
167- with :
168- path : this-repository
169-
170- - name : Copy customer config to UI tests repository for merging
171- run : |
172- cp this-repository/config/config.lindat.ui.tests.json dspace-ui-tests/customer-constants/
173-
174- - name : test
175- working-directory : dspace-ui-tests/scripts
176- env :
177- HOME_URL : https://dev-5.pc:8443/repository/
178- NAME : LINDAT
179- run : |
180- ./test.sh
181-
182- - uses : mazoea/ga-maz/end@master
183- with :
184- CHOWN_DIR : ./
185- if : ${{ always() }}
186-
187- rest-tests-after-deploy8 :
188- runs-on : ubuntu-latest
189- needs : playwright-after-deploy8
190- timeout-minutes : 45
191- steps :
192- - name : run rest-tests
193- run : |
194- curl -H "Accept: application/vnd.github.everest-preview+json" \
195- -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
196- --request POST \
197- https://api.github.com/repos/dataquest-dev/\
198- dspace-rest-test/actions/workflows/run_unittests.yml/dispatches \
199- --data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
200-
201- # wait for it to start
202- sleep 30s
203-
204- # get result of last job
205- RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
206-
207- # while job did not finish, sleep
208- while [[ $RES == 'null' ]]; do
209- sleep 10s
210- RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
211- done;
212-
213- echo $RES
214- # if last result is not success, return -1 and fail
215- if [[ $RES != \"success\" ]]; then
216- echo "rest-tests have failed! check appropriate action run in the dspace-rest-test repository"
217- exit 1
218- fi;
219-
220-
221- playwright-after-import8 :
222- runs-on : dspace-test-1
223- needs : import-8
224- if : inputs.IMPORT
225- timeout-minutes : 45
226- steps :
227- - name : Checkout Playwright tests
228- uses : actions/checkout@v4
229- with :
230- repository : dataquest-dev/dspace-ui-tests
231- path : dspace-ui-tests
232- token : ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}
233-
234- - name : Checkout main repository
235- uses : actions/checkout@v4
236- with :
237- path : this-repository
238-
239- - name : Copy customer config to UI tests repository for merging
240- run : |
241- cp this-repository/config/config.lindat.ui.tests.json dspace-ui-tests/customer-constants/
242-
243- - name : test
244- working-directory : dspace-ui-tests/scripts
245- env :
246- HOME_URL : https://dev-5.pc:8443/repository/
247- NAME : LINDAT
248- run : |
249- ./test.sh
250-
251- - uses : mazoea/ga-maz/end@master
252- with :
253- CHOWN_DIR : ./
254- if : ${{ always() }}
255-
256- rest-tests-after-import8 :
257- runs-on : ubuntu-latest
258- needs : playwright-after-import8
259- timeout-minutes : 45
260- steps :
261- - name : run rest-tests
262- run : |
263- curl -H "Accept: application/vnd.github.everest-preview+json" \
264- -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
265- --request POST \
266- https://api.github.com/repos/dataquest-dev/\
267- dspace-rest-test/actions/workflows/run_unittests.yml/dispatches \
268- --data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
269-
270- # wait for it to start
271- sleep 30s
272-
273- # get result of last job
274- RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
275-
276- # while job did not finish, sleep
277- while [[ $RES == 'null' ]]; do
278- sleep 10s
279- RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
280- done;
281-
282- echo $RES
283- # if last result is not success, return -1 and fail
284- if [[ $RES != \"success\" ]]; then
285- echo "rest-tests have failed! check appropriate action run in the dspace-rest-test repository"
286- exit 1
287- fi;
0 commit comments