From 03d53428cc6fcddeb86af34594e248a39260af45 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 18:51:06 +0900 Subject: [PATCH 01/12] =?UTF-8?q?ci:=20=EC=9E=90=EB=8F=99=20ERD=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 96 +++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/automatic-erd.yml diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml new file mode 100644 index 00000000..59aafb42 --- /dev/null +++ b/.github/workflows/automatic-erd.yml @@ -0,0 +1,96 @@ +name: ERD to GitHub Pages + +on: + pull_request: + branches: [ main, develop ] + paths: + - 'src/main/resources/db/migration/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + pull-requests: write + +jobs: + generate-erd-from-flyway: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:8.0 + env: + MYSQL_USER: ${{ secrets.TEST_DB_USER }} + MYSQL_PASSWORD: ${{ secrets.TEST_DB_PASSWORD }} + MYSQL_ROOT_PASSWORD: ${{ secrets.TEST_DB_ROOT_PASSWORD }} + MYSQL_DATABASE: testdb + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Download Flyway Command-line + run: | + wget -qO- "https://download.red-gate.com/maven/release/org/flywaydb/flyway-commandline/10.13.0/flyway-commandline-10.13.0-linux-x64.tar.gz" | tar -xvz + echo "$(pwd)/flyway-10.13.0" >> $GITHUB_PATH + + - name: Run Flyway migrations + run: | + flyway -url=jdbc:mysql://127.0.0.1:3306/testdb -user=${{ secrets.TEST_DB_USER }} -password=${{ secrets.TEST_DB_PASSWORD }} -locations=filesystem:src/main/resources/db/migration migrate + shell: bash + + - name: Dump database schema + run: | + mkdir -p erd + mysqldump -h 127.0.0.1 -u ${{ secrets.TEST_DB_USER }} -p${{ secrets.TEST_DB_PASSWORD }} --no-data --skip-comments testdb > erd/schema.sql + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '21' + + - name: Install dbml-cli + run: npm install -g @dbml/cli + + - name: Convert SQL to DBML + run: | + sql2dbml erd/schema.sql --mysql -o erd/schema.dbml + + - name: Render ERD to PNG + run: | + dbml-renderer -i erd/schema.dbml -o erd/erd.png + + - name: Generate HTML wrapper + run: | + echo "ERD Preview

ERD Preview for PR #${{ github.event.pull_request.number }}

" > erd/index.html + + - name: Deploy ERD to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./erd + force_orphan: true + + - name: Comment on PR with ERD Link + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + πŸ“Œ μ΅œμ‹  ERDκ°€ μžλ™ μƒμ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€. + + πŸ‘‰ [ERD λ³΄λŸ¬κ°€κΈ°](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/) From 75e8017009631ee8d254d94e27f7d2262e6316cf Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 18:53:07 +0900 Subject: [PATCH 02/12] =?UTF-8?q?ci:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EC=84=A4=EC=A0=95=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index 59aafb42..e1d7c6df 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -2,9 +2,8 @@ name: ERD to GitHub Pages on: pull_request: - branches: [ main, develop ] - paths: - - 'src/main/resources/db/migration/**' + branches: [ "**" ] + paths: [ "**" ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} From bf0be3c6d1090e60fd9113ee221b99b673b43a56 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 18:56:17 +0900 Subject: [PATCH 03/12] =?UTF-8?q?ci:=20flyway=20=EB=8B=A4=EC=9A=B4?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index e1d7c6df..c9bcaea7 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -43,9 +43,10 @@ jobs: java-version: '21' distribution: 'temurin' - - name: Download Flyway Command-line + - name: Download Flyway run: | - wget -qO- "https://download.red-gate.com/maven/release/org/flywaydb/flyway-commandline/10.13.0/flyway-commandline-10.13.0-linux-x64.tar.gz" | tar -xvz + curl -sSL "https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/10.13.0/flyway-commandline-10.13.0-linux-x64.tar.gz" -o flyway.tar.gz + tar -xzf flyway.tar.gz echo "$(pwd)/flyway-10.13.0" >> $GITHUB_PATH - name: Run Flyway migrations From 6c61309233824a25806fdf54148917cbcbafd5e3 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 18:58:10 +0900 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20mysql=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index c9bcaea7..be21430a 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -51,7 +51,10 @@ jobs: - name: Run Flyway migrations run: | - flyway -url=jdbc:mysql://127.0.0.1:3306/testdb -user=${{ secrets.TEST_DB_USER }} -password=${{ secrets.TEST_DB_PASSWORD }} -locations=filesystem:src/main/resources/db/migration migrate + flyway -url=jdbc:mysql://127.0.0.1:3306/testdb?allowPublicKeyRetrieval=true&useSSL=false \ + -user=${{ secrets.TEST_DB_USER }} \ + -password=${{ secrets.TEST_DB_PASSWORD }} \ + -locations=filesystem:src/main/resources/db/migration migrate shell: bash - name: Dump database schema From e4ca6571365df27b33b32f32511b2b379b66ab6a Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 18:59:59 +0900 Subject: [PATCH 05/12] =?UTF-8?q?fix:=20=EB=AA=85=EB=A0=B9=EC=96=B4=20?= =?UTF-8?q?=ED=95=9C=EC=A4=84=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index be21430a..178a4cff 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -51,11 +51,8 @@ jobs: - name: Run Flyway migrations run: | - flyway -url=jdbc:mysql://127.0.0.1:3306/testdb?allowPublicKeyRetrieval=true&useSSL=false \ - -user=${{ secrets.TEST_DB_USER }} \ - -password=${{ secrets.TEST_DB_PASSWORD }} \ - -locations=filesystem:src/main/resources/db/migration migrate - shell: bash + flyway -url="jdbc:mysql://127.0.0.1:3306/testdb?allowPublicKeyRetrieval=true&useSSL=false" -user=${{ secrets.TEST_DB_USER }} -password=${{ secrets.TEST_DB_PASSWORD }} -locations=filesystem:src/main/resources/db/migration migrate + shell: bash - name: Dump database schema run: | From 8c338950b208009899f8ac270f3cf71f7ca02893 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:01:33 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20=EC=9D=B8=EB=8D=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index 178a4cff..5d72efae 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -52,7 +52,7 @@ jobs: - name: Run Flyway migrations run: | flyway -url="jdbc:mysql://127.0.0.1:3306/testdb?allowPublicKeyRetrieval=true&useSSL=false" -user=${{ secrets.TEST_DB_USER }} -password=${{ secrets.TEST_DB_PASSWORD }} -locations=filesystem:src/main/resources/db/migration migrate - shell: bash + shell: bash - name: Dump database schema run: | From 276001d1fb1e1dfdd3b1ccdbc2dfd6392e227b56 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:04:12 +0900 Subject: [PATCH 07/12] =?UTF-8?q?fix:=20node=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index 5d72efae..44e885ee 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -62,7 +62,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '21' + node-version: '20' - name: Install dbml-cli run: npm install -g @dbml/cli From 14aa544a6bcd387d8815669f56060c7d0e222b87 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:08:27 +0900 Subject: [PATCH 08/12] =?UTF-8?q?fix:=20=EB=A0=8C=EB=8D=94=20=EB=AA=85?= =?UTF-8?q?=EB=A0=B9=EC=96=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index 44e885ee..db005857 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -73,7 +73,7 @@ jobs: - name: Render ERD to PNG run: | - dbml-renderer -i erd/schema.dbml -o erd/erd.png + run: render -i erd/schema.dbml -o erd/erd.png - name: Generate HTML wrapper run: | From b30ea17a5eefa1ddf6deae2adf4f38147934513e Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:10:30 +0900 Subject: [PATCH 09/12] =?UTF-8?q?fix:=20=EB=A0=8C=EB=8D=94=20=EB=AA=85?= =?UTF-8?q?=EB=A0=B9=EC=96=B4=20=EC=9E=AC=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index db005857..82f6a6ae 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -73,7 +73,7 @@ jobs: - name: Render ERD to PNG run: | - run: render -i erd/schema.dbml -o erd/erd.png + render -i erd/schema.dbml -o erd/erd.png - name: Generate HTML wrapper run: | From 1eb96ac49004cef62575d1a6e0afca8aedc82953 Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:14:19 +0900 Subject: [PATCH 10/12] =?UTF-8?q?fix:=20=EC=84=A4=EC=B9=98=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index 82f6a6ae..39596e27 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -64,8 +64,9 @@ jobs: with: node-version: '20' - - name: Install dbml-cli - run: npm install -g @dbml/cli + - name: Install dbml-cli and renderer + run: | + npm install -g @dbml/cli @dbml/renderer - name: Convert SQL to DBML run: | @@ -73,7 +74,7 @@ jobs: - name: Render ERD to PNG run: | - render -i erd/schema.dbml -o erd/erd.png + dbml-render -i erd/schema.dbml -o erd/erd.png - name: Generate HTML wrapper run: | From 2c1cc591b004dd3e45177ac25fe5cef93ed1edec Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:48:41 +0900 Subject: [PATCH 11/12] =?UTF-8?q?fix:=20=EC=84=A4=EC=B9=98=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index 39596e27..b5168b44 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -66,7 +66,7 @@ jobs: - name: Install dbml-cli and renderer run: | - npm install -g @dbml/cli @dbml/renderer + npm install -g @dbml/cli - name: Convert SQL to DBML run: | From 6e9f2ec4c472b7765b2d75c9aa6d5e2fac1d291b Mon Sep 17 00:00:00 2001 From: lvalentine6 Date: Fri, 11 Jul 2025 19:53:39 +0900 Subject: [PATCH 12/12] =?UTF-8?q?fix:=20=EC=84=A4=EC=B9=98=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automatic-erd.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/automatic-erd.yml b/.github/workflows/automatic-erd.yml index b5168b44..309bd73c 100644 --- a/.github/workflows/automatic-erd.yml +++ b/.github/workflows/automatic-erd.yml @@ -64,21 +64,20 @@ jobs: with: node-version: '20' - - name: Install dbml-cli and renderer - run: | - npm install -g @dbml/cli + - name: Install DBML Tools + run: npm install -g @dbml/cli @softwaretechnik/dbml-renderer - name: Convert SQL to DBML run: | - sql2dbml erd/schema.sql --mysql -o erd/schema.dbml + npx sql2dbml erd/schema.sql --mysql -o erd/schema.dbml - - name: Render ERD to PNG + - name: Render ERD to SVG run: | - dbml-render -i erd/schema.dbml -o erd/erd.png + npx dbml-renderer -i erd/schema.dbml -o erd/erd.svg - name: Generate HTML wrapper run: | - echo "ERD Preview

ERD Preview for PR #${{ github.event.pull_request.number }}

" > erd/index.html + echo "ERD Preview

ERD Preview for PR #${{ github.event.pull_request.number }}

" > erd/index.html - name: Deploy ERD to GitHub Pages uses: peaceiris/actions-gh-pages@v4