Skip to content

Commit

Permalink
add manual workflow for deploying db
Browse files Browse the repository at this point in the history
  • Loading branch information
ollyg committed Dec 31, 2024
1 parent a69bc4e commit bf91e59
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/demo-db-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy Demo Database
on:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'With build debug'
required: false
default: false
jobs:
demo_db_redeploy:
name: Redeploy Demo DB
runs-on: ubuntu-latest
container:
image: 'netdisco/netdisco:latest-backend'
options: '--user root --entrypoint /bin/ash'
volumes:
- '/home/runner/work:/github/workspace'
defaults:
run:
working-directory: /github/workspace/netdisco/netdisco
steps:
- name: Install base packages
run: apk add tmux bash curl sudo xz
- name: Install packages
run: apk add openssh-client gcc make musl-dev musl-obstack-dev python3 perl-dev unzip
- name: Install fake apt-get
run: echo 'if [ "$1" == "update" ]; then exec apk update; else exec apk add openssh-client xz; fi' > /usr/local/bin/apt-get && chmod +x /usr/local/bin/apt-get

- name: Check out latest code
uses: actions/checkout@v1

- name: Fix owner of checkout
run: chown -R netdisco:netdisco /github/workspace/netdisco/netdisco

- name: Reinitialise DB
env:
PGUSER: ${{ secrets.DEMO_PGUSER }}
PGPASSWORD: ${{ secrets.DEMO_PGPASSWORD }}
PGHOST: ${{ secrets.DEMO_PGHOST }}
PGDATABASE: ${{ secrets.DEMO_PGDATABASE }}
run: |
psql -c "DROP OWNED BY $PGUSER CASCADE"
psql -c "CREATE SCHEMA public"
curl -LO https://github.com/netdisco/netdisco2-demo/raw/master/netdisco2-demo-cumulus-clean.db.sql
psql -X -v ON_ERROR_STOP=0 -v ON_ERROR_ROLLBACK=on -d ${{ env.PGDATABASE }} -f netdisco2-demo-cumulus-clean.db.sql
- name: Update schema
env:
NETDISCO_HOME: /github/workspace/netdisco/netdisco
POETRY_CACHE_DIR: /home/netdisco/python/cache/pypoetry
NETDISCO_DB_USER: ${{ secrets.DEMO_PGUSER }}
NETDISCO_DB_PASS: ${{ secrets.DEMO_PGPASSWORD }}
NETDISCO_DB_HOST: ${{ secrets.DEMO_PGHOST }}
NETDISCO_DB_NAME: ${{ secrets.DEMO_PGDATABASE }}
run: |
/home/netdisco/bin/localenv /github/workspace/netdisco/netdisco/bin/netdisco-db-deploy
/home/netdisco/bin/localenv /github/workspace/netdisco/netdisco/bin/netdisco-do stats -D
/home/netdisco/bin/localenv /github/workspace/netdisco/netdisco/bin/netdisco-do loadmibs -D
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: always() && github.event.inputs.debug_dbdeploy_enabled == 'true'
# with:
# sudo: true

0 comments on commit bf91e59

Please sign in to comment.