Skip to content

Commit

Permalink
Merge pull request #246 from gematik/johannes/move-generate
Browse files Browse the repository at this point in the history
Move generate-images workflow out of repo
  • Loading branch information
Johennes committed Jun 20, 2024
2 parents f420d91 + c727c6c commit 86664a8
Showing 1 changed file with 6 additions and 123 deletions.
129 changes: 6 additions & 123 deletions .github/workflows/generate-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,128 +14,11 @@ on:
env:
DRAWIO_VERSION: 24.2.5
PLANTUML_VERSION: 1.2024.4
SRCDIR: src/images
OUTDIR: images/generated

jobs:
drawio:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint draw.io sources
uses: gematik/github-image-actions/.github/actions/lint-drawio@2b70671f414528810d7d1e2236a73137ca2857a9

- name: Set up Xvfb & draw.io desktop
run: |
wget -q https://github.com/jgraph/drawio-desktop/releases/download/v${{ env.DRAWIO_VERSION }}/drawio-amd64-${{ env.DRAWIO_VERSION }}.deb
sudo apt-get update
sudo apt-get install --yes --no-install-recommends xvfb ./drawio-amd64-${{ env.DRAWIO_VERSION }}.deb
- name: Prepare output folder
run: |
rm -rf "${{ env.OUTDIR }}"
mkdir -p "${{ env.OUTDIR }}"
- name: Export draw.io files as png / svg
run: |
# draw.io desktop requires a running X server
export DISPLAY=:42
Xvfb :42 -nolisten unix &
for ext in png svg; do
# Nuke everything that's not a draw.io source file so that draw.io desktop doesn't waste time trying to use it as input
find "${{ env.SRCDIR }}" -not -name "*.drawio" -exec rm -v "{}" \;
# The chromium args need to be specified last because of whatever
drawio --export --recursive --format $ext "${{ env.SRCDIR }}" --no-sandbox --disable-gpu --disable-dev-shm-usage
rsync -v --recursive --include="*.$ext" --filter="-! */" "${{ env.SRCDIR }}"/* "${{ env.OUTDIR }}"
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: images-drawio
path: ${{ env.OUTDIR }}/**

plantuml:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint PlantUML sources
uses: gematik/github-image-actions/.github/actions/lint-plantuml@2b70671f414528810d7d1e2236a73137ca2857a9

- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
check-latest: true

- name: Set up Graphviz
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends graphviz
- name: Download PlantUML JAR
run: |
# Ironically, manually fetching the JAR is faster than installing the Debian plantuml package
wget -O plantuml.jar "https://github.com/plantuml/plantuml/releases/download/v${{ env.PLANTUML_VERSION }}/plantuml-${{ env.PLANTUML_VERSION }}.jar"
- name: Prepare output folder
run: |
rm -rf "${{ env.OUTDIR }}"
mkdir -p "${{ env.OUTDIR }}"
- name: Export PlantUML files as png / svg
run: |
for ext in png svg; do
java -jar plantuml.jar -t$ext -v -nometadata -failfast2 -nbthread auto -o "." "${{ env.SRCDIR }}/**.puml"
rsync -v --recursive --include="*.$ext" --filter="-! */" "${{ env.SRCDIR }}"/* "${{ env.OUTDIR }}"
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: images-plantuml
path: ${{ env.OUTDIR }}/**

commit:
needs: [drawio, plantuml]
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Prepare output folder
run: |
rm -rf "${{ env.OUTDIR }}"
mkdir -p "${{ env.OUTDIR }}"
- name: Download draw.io artifact
uses: actions/download-artifact@v4
with:
name: images-drawio
path: ${{ env.OUTDIR }}

- name: Download PlantUML artifact
uses: actions/download-artifact@v4
with:
name: images-plantuml
path: ${{ env.OUTDIR }}

- name: Lint AsciiDoc
uses: gematik/github-image-actions/.github/actions/lint-asciidoc@2b70671f414528810d7d1e2236a73137ca2857a9

- name: Add & Commit
uses: EndBug/add-and-commit@v9
with:
add: ${{ env.OUTDIR }}
pull: --rebase --autostash
generate:
uses: gematik/github-image-actions/.github/workflows/generate-images.yml@17f3811800b3c8e0d913d934cd8c01bc954e1bb8
with:
srcdir: src/images
outdir: images/generated
ref: 17f3811800b3c8e0d913d934cd8c01bc954e1bb8

0 comments on commit 86664a8

Please sign in to comment.