Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/erase-db/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Erase dspace db'
description: 'CI/CD Erase db'

inputs:
INSTANCE:
description: 'port suffix'
required: true
type: string
NAME:
description: 'docker compose project name'
required: true
type: string
Comment thread
Kasinhou marked this conversation as resolved.
Resolved

runs:
using: "composite"
steps:

- name: stop and remove containers
shell: bash
env:
INSTANCE: ${{ inputs.INSTANCE }}
run: |
docker stop dspacesolr$INSTANCE dspacedb$INSTANCE dspace$INSTANCE dspace-angular$INSTANCE || true
docker rm dspacesolr$INSTANCE dspacedb$INSTANCE dspace$INSTANCE dspace-angular$INSTANCE || true

- name: remove volumes
shell: bash
env:
NAME: ${{ inputs.NAME }}
run: |
echo "Removing volumes for $(docker volume ls --filter name="${NAME}_" -q)"
docker volume rm $(docker volume ls --filter name="${NAME}_" -q) || true

111 changes: 111 additions & 0 deletions .github/actions/import-db/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: 'Import dspace db'
description: 'CI/CD import db'

inputs:
DATADIR:
description: 'data dir with dump, icons'
required: true
type: string
INSTANCE:
description: 'port suffix'
required: true
type: string
ASSETSTORE:
description: 'location of assetstore folder'
required: false
type: string
ADMIN_PASSWORD:
description: 'Admin password for DSpace'
required: true
type: string
LOGDIR:
description: 'Directory for log files'
required: false
type: string
Comment thread
Kasinhou marked this conversation as resolved.
Resolved
default: ''

runs:
using: "composite"
steps:

- name: info
shell: bash
run: |
docker ps -a

- uses: actions/checkout@v4
with:
repository: dataquest-dev/dspace-import-clarin
ref: 'main'
submodules: 'recursive'
path: 'dspace-import-clarin'


- name: stop and remove containers
id: import
shell: bash
working-directory: dspace-import-clarin/scripts
env:
DATADIR: ${{ inputs.DATADIR }}
DB5PORT: 15432
DB5NAME: dspace-import-db5
DB7PORT: 543${{ inputs.INSTANCE }}
BEURL: http://dev-5.pc:8${{ inputs.INSTANCE }}/repository/server/api
BEUSERNAME: dspace.admin.dev@dataquest.sk
BEUSERPASSWORD: ${{ inputs.ADMIN_PASSWORD }}
run: |
docker stop $DB5NAME || true
echo "====="
echo Starting import DB
# create otherwise it will be created with root owner
cid=$(docker run -d --rm --name $DB5NAME -v $(pwd):/dq/scripts -v $DATADIR/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 60
# copy assetstore
echo Preparing assetstore
if [[ -z ${{ inputs.ASSETSTORE }} ]]; then
echo Location of assetstore folder is empty. Not copping assetstore
else
docker cp ${{ inputs.ASSETSTORE }} dspace${{ inputs.INSTANCE }}:/dspace/
docker exec -u root dspace${{ inputs.INSTANCE }} chown -R dspace:dspace /dspace/assetstore
fi
echo "====="
cd ../
pip install -r requirements.txt || true
Comment thread
Kasinhou marked this conversation as resolved.
Resolved
echo "====="
cd ./src
# cleanup resume
rm __temp/resume/*.json || true
# arguments of the script
# required
echo "====="
# Generate the current timestamp for the log filename
timestamp=$(date +"%y%m%d%H%M")
log_file_timestamp="${{ inputs.LOGDIR }}python.${timestamp}.log"
echo $log_file_timestamp
mkdir ../__logs
# Continuously append to the log file $log_file_timestamp. Start appending when the first file is added to the __logs folder.
inotifywait -m -e create --format "%w%f" ../__logs/ | while IFS= read -r file; do tail -F --retry "$file" >> "$log_file_timestamp" 2>/dev/null & done &
echo "====="
args=(
--resume=false
--config=backend.endpoint=$BEURL
--config=backend.user=$BEUSERNAME
--config=backend.password=$BEUSERPASSWORD
--config=db_dspace_7.port=$DB7PORT
--config=db_dspace_5.port=$DB5PORT
--config=db_utilities_5.port=$DB5PORT
--config=input.datadir=$DATADIR/data/
--config=input.icondir=$DATADIR/icon/
)
# Add --resume argument if inputs.ASSETSTORE is defined
if [ -n "${{ inputs.ASSETSTORE }}" ]; then
args+=(--assetstore=${{ inputs.ASSETSTORE }})
fi
python3 repo_import.py "${args[@]}"
- name: cleanup
shell: bash
run: |
docker stop ${{ steps.import.outputs.cid }} || true
if: ${{ always() }}

Loading
Loading