Skip to content

Commit

Permalink
erase db for more instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Paurikova2 committed Oct 21, 2024
1 parent 50ac30a commit a726235
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 18 deletions.
34 changes: 34 additions & 0 deletions .github/actions/erase-db/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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

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: |
# # condition below was found by accident and appears to be useless. Investigate later.
# be sure to have INSTANCE set
# if [[ "x${NAME}" != "dspace-" ]]; then
docker volume rm $(docker volume ls --filter name="${NAME}_" -q) || true
# fi;
38 changes: 20 additions & 18 deletions .github/workflows/erase_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ name: Erase database

on:
workflow_dispatch:
inputs:
INSTANCE:
required: true
default: '6'
type: choice
options:
- '5'
- '8'
- '6'


jobs:
restart_db:
env:
INSTANCE: 6
erase_db:
runs-on: dspace-dep-1
timeout-minutes: 5
env:
INSTANCE: ${{ inputs.INSTANCE }}
steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v4

- uses: ./.github/actions/erase-db
with:
submodules: false
- name: stop and remove containers
run: |
docker stop dspacedb$INSTANCE dspace$INSTANCE dspace-angular$INSTANCE
docker rm dspacedb$INSTANCE dspace$INSTANCE dspace-angular$INSTANCE
- name: remove volumes
if: '!cancelled()'
run: |
docker volume rm dspace-${{env.INSTANCE}}_pgdata dspace-${{env.INSTANCE}}_assetstore
- name: redeploy
if: '!cancelled()'
run: |
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/deploy.yml/dispatches --data "{\"ref\":\"refs/heads/customer/TUL\"}"
INSTANCE: ${{ env.INSTANCE }}
NAME: dspace-${{ env.INSTANCE }}

0 comments on commit a726235

Please sign in to comment.