diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ba2fb8d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,52 @@ +name: CI Tests + +on: [push] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Convert test file to png image + uses: ./ + with: + quality: 100 + scale: 1.0 + src: test/test.drawio + dest: test.png + - name: Convert test file to jpeg image + uses: ./ + with: + quality: 100 + scale: 1.0 + src: test/test.drawio + dest: test.jpeg + - name: Convert test file to svg image + uses: ./ + with: + scale: 1.0 + src: test/test.drawio + dest: test.svg + - name: Convert test file to pdf + uses: ./ + with: + scale: 1.0 + src: test/test.drawio + dest: test.pdf + - name: Upload images as artifacts + uses: actions/upload-artifact@v1 + with: + name: png + path: test.png + - uses: actions/upload-artifact@v1 + with: + name: jpeg + path: test.jpeg + - uses: actions/upload-artifact@v1 + with: + name: svg + path: test.svg + - uses: actions/upload-artifact@v1 + with: + name: pdf + path: test.pdf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ed553b6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM burnett0/alpine-drawio-batch + +ENTRYPOINT ["sh", "-c", \ +"drawio-batch \ +--quality ${INPUT_QUALITY} \ +--scale ${INPUT_SCALE} \ +${INPUT_SRC} ${INPUT_DEST}"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3f4f883 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Steven Agyekum + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0fd3ed2 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# actions-drawio ![CI Tests](https://github.com/Burnett01/actions-drawio/workflows/CI%20Tests/badge.svg) + +Convert draw.io documents to ``jpeg|png|svg|pdf`` using [drawio-batch](https://github.com/languitar/drawio-batch). + +This action makes use of the heavily optimized Docker image [(alpine-drawio-batch)](https://github.com/Burnett01/docker-images/tree/alpine-drawio-batch). + +--- + +## Usage + +You can run this action by using the ``with:`` block + +```yml + steps: + - uses: actions/checkout@v2 + - name: Convert digramm to png + uses: Burnett01/actions-drawio@1.0 + with: + src: diagramm.drawio + dest: diagramm.png +``` + +**Inputs** + ++ ``quality`` The quality for png & jpeg (eg. 100) + ++ ``scale`` The scale (eg. 1.0) + ++ ``src`` The source file (eg. input.drawio) + ++ ``dest`` The destination file (eg. output.jpeg) + +--- + +## Combinations + +You can combine this actions with other ones, such as [upload-artifact](https://github.com/actions/upload-artifact): + +```yml +steps: + - uses: actions/checkout@v2 + - name: Convert test file to png image + uses: Burnett01/actions-drawio@1.0 + with: + src: test.drawio + dest: test.png + - name: Upload image as artifact + uses: actions/upload-artifact@v1 + with: + name: png + path: test.png +``` + +--- + +## Demo/Tests + +Check the Actions tab for a live demo: + +[Live Demo](https://github.com/Burnett01/actions-drawio/actions?query=workflow%3A%22CI+Tests%22) diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..2194afe --- /dev/null +++ b/action.yml @@ -0,0 +1,24 @@ +name: 'actions-drawio' +author: 'Burnett01' +description: 'Convert draw.io documents to jpeg|png|svg|pdf.' +inputs: + quality: + description: 'Image quality for png|jpeg' + required: false + default: '100' + scale: + description: 'Scales the output file size for pixel-based output formats' + required: false + default: '1.0' + src: + description: 'Input file' + required: true + dest: + description: 'Output file' + required: true +runs: + using: 'docker' + image: 'Dockerfile' +branding: + icon: 'image' + color: 'gray-dark' diff --git a/test/test.drawio b/test/test.drawio new file mode 100644 index 0000000..c29022d --- /dev/null +++ b/test/test.drawio @@ -0,0 +1 @@ +5Zlbj9o6EMc/DY8H5Q48dtlLj3SOVHWr9jEyjkmsOnbkOFz66TsmTkiwd8VWUNEtWq3iGV/i+f8YX5iEy3L3JFFV/C8ywiaBl+0m4f0kCPwoCCb6z8v2rWW2iFpDLmlmKh0Nz/QHMUbPWBuakXpUUQnBFK3GRiw4J1iNbEhKsR1XWws2HrVCObEMzxgx2/qNZqowVt/zjo6PhOaFGXoeG8cK4e+5FA03402CcH34tO4SdX2Z+nWBMrEdmMKHSbiUQqj2qdwtCdOx7cLWtnt8wdu/tyRcndNg5iVJMosTPI9Wq0WI/zE9bBBrSDeFw4uqfRcc6AF0gMLdtqCKPFcIa88WUABboUoGJR8eD3EgeiQPSv1UdQGLkuLOoaT43sdZN1wLrh5RSZnG5yuRGeLImA0rftQ3XAomJJi44Pqd1pSxzgTR97xkcejTjkw3VSIV2Q1MJlJPRJREyT1UMd5gblTb9zy05e2RkbhDpBjg0RuR4TLv+z5qAw9GnjOlCiypHrgispIUxAkSBoPfZXQDj7l+vGtqyklddy4Yb+B1NDBfa3ftG2RCS3cWE+Yb2TZ2sXLo1EzO8ZV6MziRNwYHhrLACRIHOL3xouDEFjhLUZYNp2pvCTtSKEN10Ws3EPVNQWdoRdgnUVNFBQcfJppacOh4UsjB/51UWAmlRDmo8IHRXDuUqFqGKv2y5S7Xi9FUrNcUk2lTE1m3/y3shqSdmWtOUHk8fC6TVsJ4TEcU2XREiSurXIGNxGaj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