-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
63 lines (58 loc) · 1.85 KB
/
action.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
name: 'Generate Structurizr Diagrams Images from DSL'
description: 'Automatically generates and updates Structurizr diagrams images on pull requests that modifies DSL.'
branding:
icon: 'activity'
color: 'white'
inputs:
repo-token:
description: 'GITHUB_TOKEN from secrets'
required: true
workspace-path:
description: 'Path to the DSL file'
required: true
default: 'docs/workspace.dsl'
output-path:
description: 'Path to the generated images'
required: true
default: 'docs/diagrams'
runs:
using: 'composite'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ inputs.repo-token }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Git
run: git config --global --add safe.directory $PWD
shell: bash
- name: Generate Diagram Images
run: |
echo "Actual folder is"
echo $PWD
/usr/local/structurizr-cli/structurizr.sh export -workspace ${{ inputs.workspace-path }} -format plantuml -output ${{ inputs.output-path }}
cd ${{ inputs.output-path }}
echo 'Generating PNGs...'
plantuml -tpng *.puml
shell: bash
- name: Check for Changes
id: check_changes
run: |
git add *.png
if git diff --staged --quiet; then
echo "CHANGES_EXIST=false" >> $GITHUB_ENV
else
echo "CHANGES_EXIST=true" >> $GITHUB_ENV
fi
shell: bash
- name: Commit and Push Diagrams
if: env.CHANGES_EXIST == 'true'
env:
GITHUB_TOKEN: ${{ inputs.repo-token }}
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
git commit -m "chores(C4 diagrams): Update Structurizr diagrams"
git push origin HEAD:${GITHUB_HEAD_REF}
shell: bash