-
Notifications
You must be signed in to change notification settings - Fork 0
[Ci] 자동 ERD 생성 워크플로 구현 #74
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
03d5342
ci: 자동 ERD 생성 워크플로 구현
lvalentine6 75e8017
ci: 테스트를 위한 설정 변경
lvalentine6 bf0be3c
ci: flyway 다운로드 방식 변경
lvalentine6 6c61309
fix: mysql 연결 방식 수정
lvalentine6 e4ca657
fix: 명령어 한줄로 수정
lvalentine6 8c33895
fix: 인덴트 수정
lvalentine6 276001d
fix: node 버전 수정
lvalentine6 14aa544
fix: 렌더 명령어 수정
lvalentine6 b30ea17
fix: 렌더 명령어 재수정
lvalentine6 1eb96ac
fix: 설치 패키지 변경
lvalentine6 2c1cc59
fix: 설치 패키지 변경
lvalentine6 6e9f2ec
fix: 설치 패키지 수정
lvalentine6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: ERD to GitHub Pages | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ "**" ] | ||
| paths: [ "**" ] | ||
|
|
||
| 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 | ||
| run: | | ||
| 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 | ||
| 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 | ||
|
|
||
| - 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: '20' | ||
|
|
||
| - name: Install DBML Tools | ||
| run: npm install -g @dbml/cli @softwaretechnik/dbml-renderer | ||
|
|
||
| - name: Convert SQL to DBML | ||
| run: | | ||
| npx sql2dbml erd/schema.sql --mysql -o erd/schema.dbml | ||
|
|
||
| - name: Render ERD to SVG | ||
| run: | | ||
| npx dbml-renderer -i erd/schema.dbml -o erd/erd.svg | ||
|
|
||
| - name: Generate HTML wrapper | ||
| run: | | ||
| echo "<html><head><title>ERD Preview</title></head><body><h2>ERD Preview for PR #${{ github.event.pull_request.number }}</h2><img src='erd.svg' style='max-width:100%;'/></body></html>" > 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 }}/) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.