From c14e7f64dc4c32d3c42baf69e4e0b28f29d9d256 Mon Sep 17 00:00:00 2001 From: FunamaYukina Date: Wed, 25 Dec 2024 21:12:03 +0900 Subject: [PATCH 1/3] Set up Liam ERD on GitHub Pages --- .github/workflows/github-pages.yml | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/github-pages.yml diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml new file mode 100644 index 0000000..caa30cf --- /dev/null +++ b/.github/workflows/github-pages.yml @@ -0,0 +1,86 @@ +name: Deploy GitHub Pages + +# see also https://github.com/giselles-ai/erd/settings/pages + +on: + # NOTE: Regardless of whether it's a push or a workflow_dispatch, we must specify the branch or tag for deployment in each environment. + # see https://github.com/giselles-ai/erd/settings/environments + push: + branches: + - gh-pages + - main + paths: + - .github/workflows/github-pages.yml + - migrations/**/*.sql + workflow_dispatch: + schedule: + # Schedule: Runs at 9:00 AM JST every day. + - cron: "0 0 * * *" + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # NOTE: Following the example below, the job is structured into distinct build and deploy phases. + # see https://docs.github.com/ja/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages + build: + runs-on: ubuntu-latest + timeout-minutes: 20 + + services: + # Note: Required for Step 2: Prepare the input file. + postgres: + image: postgres:15 + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + env: + POSTGRES_PASSWORD: password + + steps: + # Step 1: Checkout the repository + - name: Checkout the repository + uses: actions/checkout@v4 + with: + repository: giselles-ai/giselle + + # Step 2: Prepare the input file + - name: Prepare the input file (dump.sql) + shell: bash + run: | + pg_dump_docker_image="postgres:16.6-bookworm" # ubuntu-latest pg_dump command is a bit old. + dbname="development" + echo "CREATE DATABASE ${dbname}" | psql "postgres://postgres:password@0.0.0.0:5432" + cat migrations/*.sql | psql "postgres://postgres:password@0.0.0.0:5432/${dbname}" + docker run --rm \ + --network host \ + ${pg_dump_docker_image} \ + pg_dump --schema-only --no-privileges --no-owner \ + "postgres://postgres:password@0.0.0.0:5432/${dbname}" > dump.sql + + # Step 3: Generate ERD (Entity-Relationship Diagram) to `./_site` + - name: Generate ERD + run: npx @liam-hq/cli@latest erd build --input dump.sql --format postgres + - run: mv ./dist ./_site + + # Step 4: Upload Artifact + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: build + permissions: + id-token: write + pages: write + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From c98687fdef5fa518a14511e3e67f95cdd0c30a16 Mon Sep 17 00:00:00 2001 From: FunamaYukina Date: Thu, 26 Dec 2024 10:37:55 +0900 Subject: [PATCH 2/3] Update GitHub Actions workflow to use PostgreSQL 16.6 and remove SQL migration path --- .github/workflows/github-pages.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index caa30cf..ea783ca 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -11,7 +11,6 @@ on: - main paths: - .github/workflows/github-pages.yml - - migrations/**/*.sql workflow_dispatch: schedule: # Schedule: Runs at 9:00 AM JST every day. @@ -31,7 +30,7 @@ jobs: services: # Note: Required for Step 2: Prepare the input file. postgres: - image: postgres:15 + image: postgres:16.6-bookworm ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 From 28c53732d83f8a5c4aedb5bd3c1103857bd11a4c Mon Sep 17 00:00:00 2001 From: FunamaYukina Date: Thu, 26 Dec 2024 11:49:12 +0900 Subject: [PATCH 3/3] remove schedule comment and fix documentation link --- .github/workflows/github-pages.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index ea783ca..aa98947 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -13,7 +13,6 @@ on: - .github/workflows/github-pages.yml workflow_dispatch: schedule: - # Schedule: Runs at 9:00 AM JST every day. - cron: "0 0 * * *" concurrency: @@ -22,7 +21,7 @@ concurrency: jobs: # NOTE: Following the example below, the job is structured into distinct build and deploy phases. - # see https://docs.github.com/ja/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages + # see https://docs.github.com/en/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages build: runs-on: ubuntu-latest timeout-minutes: 20