Update the path to the build directory #3
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
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. | |
- 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: Execute schemaspy | |
run: docker run -u $(id -u ${USER}):$(id -g ${USER}) --network aspen-net -v $(realpath build):/output schemaspy/schemaspy:latest -t mariadb -db aspen -host mydb -port 3306 -u root -p password -s aspen | |
- name: Commit files | |
run: | | |
cd build | |
git config --local user.email "kyle@bywatersolutions.com" | |
git config --local user.name "Kyle M Hall" | |
git add . | |
git commit -m "Add changes" -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 |