Giter Club home page Giter Club logo

drawio-export-action's Introduction

Drawio Export Action

This GitHub Action will export Drawio Files based on drawio-export docker image.

Example usage

Export draw.io files inside folders tree of folder/of/drawio/files to png files using transparent background

uses: rlespinasse/drawio-export-action@v2
with:
  path: folder/of/drawio/files
  format: png
  transparent: true

.github/workflows/drawio-export.yml - Workflow to keep your draw.io export synchronized

name: Keep draw.io export synchronized
on:
  push:
    branches:
      - main
    paths:
      - "**.drawio"
      - .github/workflows/drawio-export.yml
concurrency:
  group: drawio-export-${{ github.ref }}
  cancel-in-progress: true
jobs:
  drawio-export:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Export drawio files to asciidoctor and png files
        uses: rlespinasse/drawio-export-action@v2
        with:
          format: adoc
          transparent: true
          output: drawio-assets

      - name: Get author and committer info from HEAD commit
        uses: rlespinasse/git-commit-data-action@v1
        if: github.ref == 'refs/heads/main'

      - name: Commit changed files
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: "docs: sync draw.io exported files"
          commit_user_name: "${{ env.GIT_COMMIT_COMMITTER_NAME }}"
          commit_user_email: "${{ env.GIT_COMMIT_COMMITTER_EMAIL }}"
          commit_author: "${{ env.GIT_COMMIT_AUTHOR }}"
        if: github.ref == 'refs/heads/main'

Inputs

path

Path to the drawio files to export. Default ".".

format

Exported format. Default "pdf".

Possible values: adoc, md, jpg, pdf, png, svg, vsdx, xml

output

Exported folder name. Default "export".

Relative from the exported drawio file

A file from /path/to/file.drawio will be exported to /path/to/export/file-{page}.{ext} by default.

remove-page-suffix

Remove page suffix when possible (in case of single page file)

border

Sets the border width around the diagram. Default "0".

scale

Scales the diagram size

width

Fits the generated image/pdf into the specified width, preserves aspect ratio

height

Fits the generated image/pdf into the specified height, preserves aspect ratio

crop

crops PDF to diagram size

embed-diagram

Includes a copy of the diagram for PNG or PDF

transparent

Set transparent background for PNG

quality

Output image quality for JPEG. Default "90".

uncompressed

Uncompressed XML output

action-mode

Export mode for this action. Default: auto

Possible values:

  • recent export only the changed files since a calculated reference
    • previously pushed commit on push event
    • base commit on pull request event
  • all export all drawio files without any filter
  • reference export since the reference from since-reference option
  • auto will choose the more appropriated mode
    • reference if since-reference option is set,
    • recent if the reference can be calculated,
    • all otherwise

CAUTION: When using a mode other than all, you need to checkout all the history.

- uses: actions/checkout@v3
  with:
    fetch-depth: 0

since-reference

Git Reference serving as base for export. Only when action-mode is set to 'reference'.

Miscellaneous

drawio-export-action's People

Contributors

dependabot[bot] avatar hnrc avatar rlespinasse avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

drawio-export-action's Issues

v2.x fails with missing git version

Describe the bug
Our builds using this action started failing with the following message:

Step 2/4 : RUN apt-get update && apt-get install --no-install-recommends -y git=1:2.30.2-1 && rm -rf /var/lib/apt/lists/*
   ---> Running in a471eb992ff5
  Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
  Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [[48](https://github.com/TBCTSystems/bct-common-licensing-softwarekey/actions/runs/4852448319/jobs/8647443878#step:2:48).4 kB]
  Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
  Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
  Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [237 kB]
  Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [14.6 kB]
  Fetched 8643 kB in 1s (6962 kB/s)
  Reading package lists...
  Reading package lists...
  Building dependency tree...
  Reading state information...
  E: Version '1:2.30.2-1' for 'git' was not found
  The command '/bin/sh -c apt-get update && apt-get install --no-install-recommends -y git=1:2.30.2-1 && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

To Reproduce

Use the action, our code as follows, but the error occurs during building the image from the Dockerfile:

- name: ๐Ÿ–ผ๏ธ Export drawio files to png files
      uses: rlespinasse/[email protected]
      with:
        format: png
        transparent: true
        embed-diagram: true
        path: ./docs/drawio/
        output: ./images
        action-mode: all

Expected behavior
Image builds successfully when using action

Improve action mode auto/recent on first push/force push

Currently, when a push is done for the first time or a push is force pushed :

  • If the action mode is auto, then the action mode defaults to all,
  • If the action mode is recent, then the action do nothing and stops the process properly.

Prepare the ownership change of this action

In order to improve the governance and the future of this action, I created a GitHub organization called Actions-Able which is composed of other action maintainers and co-maintainers I work with.

This issue concerns preparing the migration to this new ownership without breaking the current use of rlespinasse/drawio-export-action@... in our user workflows.

Improve testing of internal

Some use cases are difficult to test but can be simulated.
Currently, the test suite is not designed for that.

  • Update runner.sh to be tested outside the Docker image
  • Setup bat testing environment
  • Design bat tests to cover various use cases.

Failed Reference when Pushing New Branch

Describe the bug
When the action is run on a new branch push, the run fails. This is because the script cannot find the previous reference and uses 0s.

To Reproduce
Create a new branch and push a DrawIO file on that branch.

Expected behavior
Should reference the last commit from the previous branch

Screenshots
image
image

Run from pre-built image instead of Dockerfile

Is your feature request related to a problem? Please describe.

The action currently uses image: 'Dockerfile' which means the Docker image is rebuilt any time the action is run. This takes about a minute which for many use cases is far greater than the time needed to actually run the image.

Describe the solution you'd like

Provide a pre-built image and use image: 'docker://...' to speed up the action execution and avoid needlessly rebuilding the image.

Describe alternatives you've considered

โ€“

Additional context

โ€“

Generated file name is obscure

Issue

Suppose I have a directory assets with file diagram.drawio in it.
I have to convert the diagram.drawio to .png in the same directory.
I used the following configuration:

- name: Render .drawio Files
  uses: rlespinasse/drawio-export-action@v2
  with:
      format: png
      path: assets
      output: assets
      action-mode: all

But apparently there is no such file as assets/diagram.png.

Solution

I would like the file assets/diagram.png to be generated as a result of described above example.

Alternatives

Finally I found another action, that didn't work either, but at least it could be patched:

- name: Render .drawio Files
  uses: docker://ghcr.io/racklet/render-drawio-action:v1
  with:
      args: '"--sub-dirs=docs/assets" "--formats=png"'

However this action afaik is outdated and uses deprecated lib. I would love to use your action.
If I only knew how...

Add action-mode that only generates when the embedded image differs

Is your feature request related to a problem? Please describe.

The action appears to have parameters to embed the source image in the generated PNG and SVG files. This information could be used to only regenerate the files if the embedded source differs from the current source file.

Describe the solution you'd like

Add a new action-mode ร  la embedded-diff that regenerates the files only if the embedded source differs from the source file (or when there is no embedded source at all).

Describe alternatives you've considered

The only current alternative is to use git refs which requires a non-shallow clone.

Additional context

โ€“

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.