@@ -203,34 +203,23 @@ jobs:
203203 runs-on : ubuntu-latest
204204 needs : playwright-after-deploy8
205205 timeout-minutes : 120
206+ env :
207+ GH_TOKEN : ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}
208+ REPO : dataquest-dev/dspace-rest-test
209+ WORKFLOW : run_unittests.yml
206210 steps :
207211 - name : run rest-tests
208212 run : |
209- curl -H "Accept: application/vnd.github.everest-preview+json" \
210- -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
211- --request POST \
212- https://api.github.com/repos/dataquest-dev/\
213- dspace-rest-test/actions/workflows/run_unittests.yml/dispatches \
214- --data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
215-
216- # wait for it to start
217- sleep 30s
218-
219- # get result of last job
220- 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)
213+ OUTPUT=$(gh workflow run "$WORKFLOW" \
214+ --repo "$REPO" \
215+ --ref master \
216+ -f CUSTOMER="${{ github.ref_name }}" \
217+ -f URL="http://dev-5.pc:85/repository/server/api" 2>&1)
221218
222- # while job did not finish, sleep
223- while [[ $RES == 'null' ]]; do
224- sleep 10s
225- 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)
226- done;
219+ RUN_ID=$(echo "$OUTPUT" | grep -oE '/runs/[0-9]+' | grep -oE '[0-9]+')
227220
228- echo $RES
229- # if last result is not success, return -1 and fail
230- if [[ $RES != \"success\" ]]; then
231- echo "rest-tests have failed! check appropriate action run in the dspace-rest-test repository"
232- exit 1
233- fi;
221+ echo "Watching run: https://github.com/$REPO/actions/runs/$RUN_ID"
222+ gh run watch "$RUN_ID" --repo "$REPO" --interval 30 --exit-status
234223
235224
236225 playwright-after-import8 :
@@ -243,31 +232,20 @@ jobs:
243232 runs-on : ubuntu-latest
244233 needs : playwright-after-import8
245234 timeout-minutes : 120
235+ env :
236+ GH_TOKEN : ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}
237+ REPO : dataquest-dev/dspace-rest-test
238+ WORKFLOW : run_unittests.yml
246239 steps :
247240 - name : run rest-tests
248241 run : |
249- curl -H "Accept: application/vnd.github.everest-preview+json" \
250- -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
251- --request POST \
252- https://api.github.com/repos/dataquest-dev/\
253- dspace-rest-test/actions/workflows/run_unittests.yml/dispatches \
254- --data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
255-
256- # wait for it to start
257- sleep 30s
258-
259- # get result of last job
260- 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)
261-
262- # while job did not finish, sleep
263- while [[ $RES == 'null' ]]; do
264- sleep 10s
265- 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)
266- done;
267-
268- echo $RES
269- # if last result is not success, return -1 and fail
270- if [[ $RES != \"success\" ]]; then
271- echo "rest-tests have failed! check appropriate action run in the dspace-rest-test repository"
272- exit 1
273- fi;
242+ OUTPUT=$(gh workflow run "$WORKFLOW" \
243+ --repo "$REPO" \
244+ --ref master \
245+ -f CUSTOMER="${{ github.ref_name }}" \
246+ -f URL="http://dev-5.pc:85/repository/server/api" 2>&1)
247+
248+ RUN_ID=$(echo "$OUTPUT" | grep -oE '/runs/[0-9]+' | grep -oE '[0-9]+')
249+
250+ echo "Watching run: https://github.com/$REPO/actions/runs/$RUN_ID"
251+ gh run watch "$RUN_ID" --repo "$REPO" --interval 30 --exit-status
0 commit comments