-
Notifications
You must be signed in to change notification settings - Fork 9
141 lines (113 loc) · 4.1 KB
/
generate-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Generate images
on:
push:
branches:
- '**'
paths:
- '.github/workflows/generate-images.yml'
- 'images/generated/**'
- '**.drawio'
- '**.puml'
workflow_dispatch:
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: ./.github/actions/lint-drawio
- 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: ./.github/actions/lint-plantuml
- 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: ./.github/actions/lint-asciidoc
- name: Add & Commit
uses: EndBug/add-and-commit@v9
with:
add: ${{ env.OUTDIR }}
pull: --rebase --autostash