-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add manual workflow for deploying db
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|