|
| 1 | +name: 'Import dspace db' |
| 2 | +description: 'CI/CD import db' |
| 3 | + |
| 4 | +inputs: |
| 5 | + DATADIR: |
| 6 | + description: 'data dir with dump, icons' |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + INSTANCE: |
| 10 | + description: 'port suffix' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + ASSETSTORE: |
| 14 | + description: 'location of assetstore folder' |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + ADMIN_PASSWORD: |
| 18 | + description: 'Admin password for DSpace' |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + LOGDIR: |
| 22 | + description: 'Directory for log files' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + default: '' |
| 26 | + |
| 27 | +runs: |
| 28 | + using: "composite" |
| 29 | + steps: |
| 30 | + |
| 31 | + - name: info |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + docker ps -a |
| 35 | +
|
| 36 | + - uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + repository: dataquest-dev/dspace-import-clarin |
| 39 | + ref: 'main' |
| 40 | + submodules: 'recursive' |
| 41 | + path: 'dspace-import-clarin' |
| 42 | + |
| 43 | + |
| 44 | + - name: stop and remove containers |
| 45 | + id: import |
| 46 | + shell: bash |
| 47 | + working-directory: dspace-import-clarin/scripts |
| 48 | + env: |
| 49 | + DATADIR: ${{ inputs.DATADIR }} |
| 50 | + DB5PORT: 15432 |
| 51 | + DB5NAME: dspace-import-db5 |
| 52 | + DB7PORT: 543${{ inputs.INSTANCE }} |
| 53 | + BEURL: http://dev-5.pc:8${{ inputs.INSTANCE }}/repository/server/api |
| 54 | + BEUSERNAME: dspace.admin.dev@dataquest.sk |
| 55 | + BEUSERPASSWORD: ${{ inputs.ADMIN_PASSWORD }} |
| 56 | + run: | |
| 57 | + docker stop $DB5NAME || true |
| 58 | + echo "=====" |
| 59 | + echo Starting import DB |
| 60 | + # create otherwise it will be created with root owner |
| 61 | + 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") |
| 62 | + echo "cid=$cid" >> $GITHUB_OUTPUT |
| 63 | + sleep 60 |
| 64 | + # copy assetstore |
| 65 | + echo Preparing assetstore |
| 66 | + if [[ -z ${{ inputs.ASSETSTORE }} ]]; then |
| 67 | + echo Location of assetstore folder is empty. Not copping assetstore |
| 68 | + else |
| 69 | + docker cp ${{ inputs.ASSETSTORE }} dspace${{ inputs.INSTANCE }}:/dspace/ |
| 70 | + docker exec -u root dspace${{ inputs.INSTANCE }} chown -R dspace:dspace /dspace/assetstore |
| 71 | + fi |
| 72 | + echo "=====" |
| 73 | + cd ../ |
| 74 | + pip install -r requirements.txt || true |
| 75 | + echo "=====" |
| 76 | + cd ./src |
| 77 | + # cleanup resume |
| 78 | + rm __temp/resume/*.json || true |
| 79 | + # arguments of the script |
| 80 | + # required |
| 81 | + echo "=====" |
| 82 | + # Generate the current timestamp for the log filename |
| 83 | + timestamp=$(date +"%y%m%d%H%M") |
| 84 | + log_file_timestamp="${{ inputs.LOGDIR }}python.${timestamp}.log" |
| 85 | + echo $log_file_timestamp |
| 86 | + mkdir ../__logs |
| 87 | + # Continuously append to the log file $log_file_timestamp. Start appending when the first file is added to the __logs folder. |
| 88 | + 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 & |
| 89 | + echo "=====" |
| 90 | + args=( |
| 91 | + --resume=false |
| 92 | + --config=backend.endpoint=$BEURL |
| 93 | + --config=backend.user=$BEUSERNAME |
| 94 | + --config=backend.password=$BEUSERPASSWORD |
| 95 | + --config=db_dspace_7.port=$DB7PORT |
| 96 | + --config=db_dspace_5.port=$DB5PORT |
| 97 | + --config=db_utilities_5.port=$DB5PORT |
| 98 | + --config=input.datadir=$DATADIR/data/ |
| 99 | + --config=input.icondir=$DATADIR/icon/ |
| 100 | + ) |
| 101 | + # Add --resume argument if inputs.ASSETSTORE is defined |
| 102 | + if [ -n "${{ inputs.ASSETSTORE }}" ]; then |
| 103 | + args+=(--assetstore=${{ inputs.ASSETSTORE }}) |
| 104 | + fi |
| 105 | + python3 repo_import.py "${args[@]}" |
| 106 | + - name: cleanup |
| 107 | + shell: bash |
| 108 | + run: | |
| 109 | + docker stop ${{ steps.import.outputs.cid }} || true |
| 110 | + if: ${{ always() }} |
| 111 | + |
0 commit comments