From 40fdef071868fe5606eafb3da3b1c2f6e2525754 Mon Sep 17 00:00:00 2001 From: jm Date: Tue, 7 Nov 2023 11:02:05 +0100 Subject: [PATCH] [devOps] create new dspace instance with imported data --- .github/workflows/deploy.yml | 14 +++++++++++++- .github/workflows/import.yml | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/import.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3ef793e9e1f..d0bfb93f209 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: false - - name: deploy + - name: deploy to dev-5 run: | cd $GITHUB_WORKSPACE/build-scripts/run/ pwd @@ -39,3 +39,15 @@ jobs: export ENVFILE=$(pwd)/.env.dev-5 ./start.sh dspace-5 + + - name: deploy dspace-import on dev-5 + working-directory: build-scripts/run/ + run: | + ENVFILE=/opt/dspace-envs/.env.dspace.imported.dev-5 ./start.sh dspace-5-import + sleep 120 + curl -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \ + --request POST \ + https://api.github.com/repos/dataquest-dev/ \ + dspace-angular/actions/workflows/import.yml/dispatches \ + --data "{\"ref\":\"refs/heads/dtq-dev\"}" diff --git a/.github/workflows/import.yml b/.github/workflows/import.yml new file mode 100644 index 00000000000..b8e49867c27 --- /dev/null +++ b/.github/workflows/import.yml @@ -0,0 +1,35 @@ +name: Import DSpace v5 + +on: + workflow_dispatch: + +jobs: + deploy: + runs-on: dspace-dep-1 + steps: + - uses: actions/checkout@v4 + with: + repository: dataquest-dev/dspace-python-api + path: dspace-python-api + ref: 'refactor_jm' + + - name: deploy dspace-import on dev-5 + id: import + working-directory: dspace-python-api/scripts + run: | + docker stop dspace-import-db5 || true + DB5PORT=15432 + cid=$(docker run -d --name dspace-import-db5 -v $pwd:/dq/scripts -v %cd%/../input/dump:/dq/dump \ + -p 127.0.0.1:$DB5PORT:5432 -e POSTGRES_DB=empty -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=dspace postgres /bin/bash -c "cd /dq/scripts && ./init.dspacedb5.sh") + echo "cid=$cid" >> $GITHUB_OUTPUT + sleep 10 + cd ../src + # cleanup resume + rm __temp/resume/*.json || true + echo python repo_import.py --resume=false + + - name: cleanup + run: | + docker stop ${{ steps.import.outputs.cid }} || true + if: ${{ always() }} + \ No newline at end of file