Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up Liam ERD on GitHub Pages #1

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not necessary because this file is not in giselles-ai/erd due to repository split.

Suggested change
- migrations/**/*.sql

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.Thank you for teaching me🙏.
I've removed it. c98687f

workflow_dispatch:
schedule:
# Schedule: Runs at 9:00 AM JST every day.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: It's unclear how frequently this schedule will be viewed by Japanese users, so feel free to remove this note.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right🙏.
I've deleted the note. 28c5373

- cron: "0 0 * * *"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI:

This is not relevant for this repository, but public repositories have this limitation.

🔗 https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule

In a public repository, scheduled workflows are automatically disabled when no repository activity has occurred in 60 days. For information on re-enabling a disabled workflow, see Disabling and enabling a workflow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the information! I didn't know that. 👀


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@masutaka masutaka Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also good to let the browser settings determine the language. 😄
https://docs.github.com/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct as well.👍 Thank you!
28c5373

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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: The version of postgres in line 34 is 15, so it should match either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry.
I've corrected it.(use postgres:16.6-bookworm ) c98687f

dbname="development"
echo "CREATE DATABASE ${dbname}" | psql "postgres://postgres:[email protected]:5432"
cat migrations/*.sql | psql "postgres://postgres:[email protected]:5432/${dbname}"
docker run --rm \
--network host \
${pg_dump_docker_image} \
pg_dump --schema-only --no-privileges --no-owner \
"postgres://postgres:[email protected]: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
Loading