-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (67 loc) · 2.21 KB
/
create-diagrams.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
# This is a workflow to automatically generate diagram SVGs
name: Create mermaid diagrams
on:
# Run on pull requests into readmedocs-staging
pull_request:
types: [ closed ]
branches: [ master ]
# Enable manual triggers (for testing)
workflow_dispatch:
jobs:
create-diagrams:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
name: Create diagram SVGs
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23
with:
sha: ${{ github.event.pull_request.head.sha }}
base_sha: ${{ github.event.pull_request.base.sha }}^
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file"
done
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Generate diagrams
run: |
npm install @mermaid-js/mermaid-cli
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
filename=$(basename "$file")
fname="${filename%.*}"
ext="${filename##*.}"
echo "file: $file ; filename: $filename ; fname: $fname ; ext: $ext"
if [ "$ext" = "mmd" ]
then
echo "$file with extension .mmd has changed"
npx mmdc -i $file -o static/diagrams/svg/${fname}.svg --configFile static/diagrams/config.json
fi
done
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
add-paths: static/diagrams/svg/*
labels: |
mermaid diagram
automated pr
base: master
draft: false
delete-branch: true
commit-message: Add mermaid diagram(s) [automated]
title: Add mermaid diagram(s) [automated]
branch: automated-diagrams
branch-suffix: short-commit-hash
delete-branch:
needs: create-diagrams
uses: ./.github/workflows/manual.yml
with:
branch: ${{ github.head_ref }}