Skip to content

Deploy Demo Database #7

Deploy Demo Database

Deploy Demo Database #7

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/netdisco2-demo/netdisco2-demo
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 gzip
- 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/netdisco2-demo/netdisco2-demo
- name: Reinitialise DB
env:
PGUSER: ${{ secrets.DEMO_PGUSER }}
PGPASSWORD: ${{ secrets.DEMO_PGPASSWORD }}
PGHOST: ${{ secrets.DEMO_PGHOST }}
PGDATABASE: ${{ secrets.DEMO_PGDATABASE }}
NETDISCO_HOME: /home/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: |
curl -LO https://github.com/netdisco/netdisco2-demo/raw/master/netdisco2-demo-cumulus-clean.db.sql
curl -LO https://raw.githubusercontent.com/netdisco/upstream-sources/refs/heads/master/bootstrap/netdisco-lookup-tables.sql
curl -LO https://github.com/netdisco/netdisco2-demo/raw/master/netdisco2-demo-snmp-object-data.sql.gz
psql -c "DROP OWNED BY $PGUSER CASCADE"
psql -c "CREATE SCHEMA public"
psql -X -v ON_ERROR_STOP=0 -v ON_ERROR_ROLLBACK=on -d ${{ env.PGDATABASE }} -f netdisco2-demo-cumulus-clean.db.sql
/home/netdisco/bin/localenv /home/netdisco/bin/netdisco-db-deploy
psql -X -v ON_ERROR_STOP=0 -v ON_ERROR_ROLLBACK=on -d ${{ env.PGDATABASE }} -f netdisco-lookup-tables.sql
gunzip netdisco2-demo-snmp-object-data.sql.gz
psql -X -v ON_ERROR_STOP=0 -v ON_ERROR_ROLLBACK=on -d ${{ env.PGDATABASE }} -f netdisco2-demo-snmp-object-data.sql
/home/netdisco/bin/localenv /home/netdisco/bin/netdisco-do stats -D
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: always() && github.event.inputs.debug_enabled == 'true'
#with:
# sudo: true