Anyone have success setting up a continuous integration using github actions?

I am testing out sync of github to dbdocs

  • I am attempting to use the git hub actions script here: CI Integration | dbdocs Docs
  • But I am getting an invalid workflow file error when it runs in git hub. See image below…

Anyone else have success with setting up these actions?
What can I try to resolve my issue?

Can you try again by increasing the indentation level from line 11 and afterward?

@Thi_Nguyen - Thanks. Workflow has now run! Will let you know if it is succcessful.

1 Like

Did this get any traction? I have spent most of the day getting a proof of concept working, but have not taken the step to putting it into a CI pipeline. I have:

  • running a MSSQL cursor query to generate a file (using a different format, could not get it working in the dbms format at this stage) based on the current database’s actual table/column structure and generate an output file
  • running a python script to take that output file and parsing it into dbms format output

With the release of the API, it would be a trivial matter to include the diagram’s id and publish this dbms format into the actual tool, making sure that your ERD is always up to date with your code, but setting up those kind of CI/CD pipelines are not something that I have done yet.

Hi @fw_sol_walters ,

I understand that you want to find the way to publish the changes of your MSSQL to dbdiagram via updating DBML in CI right? Please correct if I’m wrong.

Currently, dbdiagram support public API, you can see details at dbdiagram Public API | dbdiagram Docs. You can subscribe to our personal pro plan or team trial (7 days) to experiment with dbdiagram API.

Thanks.

yes, that’s correct. The OP seemed like he was trying to get something working, but I was just wondering if there was already a tool or process that someone else had created. My ideal would be that it is published as part of the build process, started after the build and test verify, and auto updates the latest schema to the web. It looks like all parts of that process exist, it just requires building to set it up.

Hi @fw_sol_walters ,

Thank you for the details.

Let me note your high-level workflow:

  1. Connect to MSSQL database and generate SQL changes

  2. Run python script to convert SQL to DBML

  3. Publish the DBML to dbdiagram

I’m not sure that a github action could help you since I don’t know much about your connect to MSSQL setup step.

I hope the following github action (just placeholder) could help you for the high-level idea.

name: Publish DBML to DBdiagram

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Generate SQL from MSSQL
        run: ./your-script

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: 3.12

      - name: Convert SQL to DBML
        run: python your_python_script.py

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22

      - name: Load DBdiagram API Token
        run: echo "DBDIAGRAM_TOKEN=${{ secrets.DBDIAGRAM_TOKEN }}" >> $GITHUB_ENV

      # You can read the output file from the python convert step
      - name: Read DBML file
        id: read_dbml
        run: |
          DBML_CONTENT=$(cat test.dbml)
          echo "content<<EOF" >> $GITHUB_OUTPUT
          echo "$DBML_CONTENT" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Publish DBML to DBdiagram
        run: |
          curl --location --request PUT "https://api.dbdiagram.io/v1/diagrams/:diagramId" \
          --header "dbdiagram-access-token: $DBDIAGRAM_TOKEN" \
          --header "Content-Type: application/json" \
          --data "{
            \"name\": \"Updated Sample Diagram\",
            \"content\": $(echo '${{ steps.read_dbml.outputs.content }}' | jq -Rs .)
          }"

Also, please try on your side. If you could share more about your config or need any helps, please post updates on this thread.

Thanks.