Skip to content

Commit

Permalink
[devOps] import/erase workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jm committed Nov 7, 2023
1 parent 36cfd0c commit 20837f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ name: Deploy DSpace

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

jobs:
deploy:
if: github.event.inputs.INSTANCE == '' || github.event.inputs.INSTANCE == '5'
runs-on: dspace-dep-1
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
with:
submodules: false
- uses: actions/checkout@v4

- name: deploy to dev-5
run: |
cd $GITHUB_WORKSPACE/build-scripts/run/
Expand Down Expand Up @@ -41,19 +53,30 @@ jobs:
export ENVFILE=$(pwd)/.env.dev-5
./start.sh dspace-5
pre-deploy-import:
if: github.event.inputs.INSTANCE == '' || github.event.inputs.INSTANCE == '8'
uses: dataquest-dev/dspace-angular/.github/workflows/erase_db.yml@dtq-dev
with:
INSTANCE: '8'

deploy-import:
if: github.event.inputs.INSTANCE == '' || github.event.inputs.INSTANCE == '8'
needs: pre-deploy-import
runs-on: dspace-dep-1
timeout-minutes: 5
env:
INSTANCE: '8'
steps:
- uses: actions/checkout@v4

- 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
/bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://dev-5.pc:88/server/api)" != "200" ]]; do sleep 5; done'
ENVFILE=/opt/dspace-envs/.env.dspace.imported.dev-5 ./start.sh dspace-$INSTANCE
/bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://dev-5.pc:8$INSTANCE/server/api)" != "200" ]]; do sleep 5; done'
post-deploy-import:
if: (github.event.inputs.INSTANCE == '' || github.event.inputs.INSTANCE == '8') && github.event.inputs.IMPORT == true
needs: deploy-import
uses: dataquest-dev/dspace-angular/.github/workflows/import.yml@dtq-dev
secrets: inherit
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/erase_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
timeout-minutes: 5
env:
INSTANCE: ${{ inputs.INSTANCE }}
NAME: dspace-${{ inputs.INSTANCE }}
steps:

- name: stop and remove containers
Expand All @@ -33,9 +34,4 @@ jobs:
- 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/dtq-dev\"}"
docker volume rm $NAME_pgdata $NAME_assetstore
7 changes: 0 additions & 7 deletions .github/workflows/import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@ on:
- '8'

jobs:
pre-import-cleanup:
uses: dataquest-dev/dspace-angular/.github/workflows/erase_db.yml@dtq-dev
secrets: inherit
with:
INSTANCE: ${{ inputs.INSTANCE }}

import:
runs-on: dspace-dep-1
needs: pre-import-cleanup
steps:

- uses: actions/checkout@v4
Expand Down

0 comments on commit 20837f3

Please sign in to comment.