Skip to content

Build Aspen SchemaSpy #277

Build Aspen SchemaSpy

Build Aspen SchemaSpy #277

Workflow file for this run

name: Build Aspen SchemaSpy
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * *"
jobs:
build_and_deploy:
name: Build schemaspy document and deploy gh-pages
runs-on: ubuntu-latest
services:
db:
image: mariadb:11.2.2
env:
MARIADB_ROOT_PASSWORD: password
MARIADB_DATABASE: aspen
options: --name mydb
steps:
- name: Sleep 10s
run: sleep 10
- name: Create docker network
run: docker network create aspen-net
- name: Connect db container to docker network
run: docker network connect aspen-net mydb
- name: Export additional variables
id: extracted_variables
run: |
export ASPEN_DEFAULT_BRANCH=$(curl -s https://api.github.com/repos/Aspen-Discovery/aspen-discovery | jq .default_branch)
echo "ASPEN_DEFAULT_BRANCH: $ASPEN_DEFAULT_BRANCH"
echo ::set-output name=ASPEN_DEFAULT_BRANCH::$ASPEN_DEFAULT_BRANCH
- uses: actions/checkout@v2
with:
path: build
ref: gh-pages
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- uses: actions/checkout@v2
with:
path: main
ref: main
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: list contents of build dir
run: ls -alh build
- name: List docker containers
run: docker ps
- name: Get schema file
run: wget https://raw.githubusercontent.com/Aspen-Discovery/aspen-discovery/${{ steps.extracted_variables.outputs.ASPEN_DEFAULT_BRANCH }}/install/aspen.sql
- name: cat schema file
run: cat aspen.sql
- name: Fix aspen.sql collation
run: sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' aspen.sql
- name: Setup DB
run: docker exec -i mydb sh -c 'exec mariadb -uroot -ppassword aspen' < aspen.sql
- name: Path to build dir
run: realpath build
- name: Create the version directory if it does not exist
run: mkdir build/${{ steps.extracted_variables.outputs.ASPEN_DEFAULT_BRANCH }} || true
- name: List the directories
run: ls -alh
- name: Execute schemaspy
run: docker run -u $(id -u ${USER}):$(id -g ${USER}) --network aspen-net -v $(realpath .)/build/${{ steps.extracted_variables.outputs.ASPEN_DEFAULT_BRANCH }}:/output schemaspy/schemaspy:latest -t mariadb -db aspen -host mydb -port 3306 -u root -p password -s aspen
- name: Install Template Toolkit
run: sudo apt install -y libtemplate-perl
- name: Commit files
run: |
pwd
cd build
git config --local user.email "kyle@bywatersolutions.com"
git config --local user.name "Kyle M Hall"
git add ${{ steps.extracted_variables.outputs.ASPEN_DEFAULT_BRANCH }}
DIRS=$(ls -d */)
echo "DIRS: $DIRS"
tpage --define DIRS="$DIRS" ../main/index.tt
tpage --define DIRS="$DIRS" ../main/index.tt > index.html
git add index.html
git commit -m "Add changes for ${{ steps.extracted_variables.outputs.ASPEN_DEFAULT_BRANCH }}" -a
cd ..
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
force: true
directory: build
keepalive:
name: Keep Alive
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check age and push commit if needed
run: |
LAST_COMMIT=$( git --no-pager log -1 --format=%ct )
NOW=$(date +%s)
DIFF=$(($NOW-$LAST_COMMIT))
DAYS=$(($DIFF/86400))
git config --global user.email kyle@bywatersolutions.com
git config --global user.name "Kyle M Hall"
git commit --allow-empty -m "Automated commit from keep alive workflow"
if [ "$DAYS" -gt "50" ]; then git push; fi