GITBOOK-1198: No subject #1765
This file contains 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
name: DrawIO to PNG Conversion | |
on: | |
push: | |
jobs: | |
drawio-png-conversion: | |
runs-on: ubuntu-20.04 | |
env: | |
DRAWIO: '0' | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: changed files | |
id: files | |
uses: jitterbit/get-changed-files@v1 | |
- name: Check for drawio files | |
run: | | |
export DRAWIO=0 | |
for changed_file in ${{ steps.files.outputs.added_modified }}; do | |
echo ${changed_file} | |
if [[ "${changed_file##*.}" == "drawio" ]]; then | |
export DRAWIO=1 | |
echo "DRAWIO=1" >> $GITHUB_ENV | |
break | |
fi | |
done | |
if [[ "$DRAWIO" == "0" ]]; then | |
echo "::warning::No drawio file. Exiting" | |
fi | |
- name: Install snapd | |
if: env.DRAWIO == '1' | |
run: sudo apt install snapd -y | |
- name: Install xvfb | |
if: env.DRAWIO == '1' | |
run: sudo apt -y install curl xvfb nano libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libappindicator3-1 libsecret-1-0 libgbm1 | |
- name: Install Drawio | |
if: env.DRAWIO == '1' | |
run: sudo snap install drawio | |
- name: Convert | |
if: env.DRAWIO == '1' | |
run: | | |
for changed_file in ${{ steps.files.outputs.added_modified }}; do | |
if [[ "${changed_file##*.}" == "drawio" ]]; then | |
xvfb-run -a drawio -x -f png ${changed_file} --width 1920 --border 50 --headless --disable-gpu --no-sandbox \; | |
fi | |
done | |
- name: Commit Changes | |
if: env.DRAWIO == '1' | |
uses: EndBug/add-and-commit@v7 | |
with: | |
default_author: github_actions | |
message: "Converted drawio image to png ${{ github.event.inputs.git-ref }}" | |
add: "**/*.png" |