-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
122 lines (113 loc) · 4.17 KB
/
action.yaml
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
name: "PlantUML"
description: "Generate PlantUML diagrams as SVGs"
inputs:
github-token:
description: "A GitHub PAT used to commit and push generated SVGs back into the repository."
required: true
ghcr-username:
description: "The username to use to login to ghcr.io."
required: true
ghcr-password:
description: "The password to use to login to ghcr.io."
required: true
runs:
using: "composite"
steps:
# https://github.com/docker/login-action/blob/7f58925/README.md#github-container-registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ inputs.ghcr-username }}
password: ${{ inputs.ghcr-password }}
- uses: actions/checkout@v3
with:
token: ${{ inputs.github-token }}
fetch-depth: 0
- name: Get commit range
id: commit-range
shell: bash
run: |
echo Finding relevant commit range for changed PUML files ...
echo "COMMITISH=$(${{ github.action_path }}/scripts/get-commitish.sh '${{ github.event.before }}' '${{ github.sha }}')" >> $GITHUB_OUTPUT
- name: Get parsable changed file names
id: parsable-files
shell: bash
env:
COMMITISH: ${{ steps.commit-range.outputs.COMMITISH }}
run: |
echo Parsing changed PUML file names ...
CHANGED_FILES=$( \
${{ github.action_path }}/scripts/get-changed-files.sh \
| ${{ github.action_path }}/scripts/get-shell-parsable-files.awk)
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_OUTPUT
- name: Get safe file names
id: changed-plantuml-files
shell: bash
env:
CHANGED_FILES: ${{ steps.parsable-files.outputs.CHANGED_FILES }}
run: |
echo Sanitizing changed PUML file names for shell safety ...
IFS=$'\n'
for output in $(${{ github.action_path }}/scripts/get-shell-safe-files.sh); do
echo "$output" >> $GITHUB_OUTPUT
done
- name: Removed PUML files detected
id: detected-removed-files
shell: bash
if: success()
run: |
echo Checking for removed PUML files ...
set -o pipefail
orphaned_files='${{ steps.changed-plantuml-files.outputs.orphaned_files}}'
if [[ $orphaned_files == "" ]]; then
echo No removed PUML files detected.
else
echo $orphaned_files
fi
- name: Added or modifed PUML files detected
id: detected-changed-files
shell: bash
if: success()
run: |
echo Checking for modified PUML files ...
set -o pipefail
modified_files='${{ steps.changed-plantuml-files.outputs.modified_files }}'
if [[ $modified_files == "" ]]; then
echo No PUML file changes detected.
else
echo $modified_files
fi
- name: Remove Orphaned SVG Diagrams
id: remove-orphaned-files
shell: bash
if: success() && steps.changed-plantuml-files.outputs.orphaned_files != ''
run: |
echo Removing orphaned SVG files ...
set -o pipefail
rm ${{ steps.changed-plantuml-files.outputs.orphaned_files }}
- name: Generate SVG Diagrams
id: generate-svg-diagrams
shell: bash
if: success() && steps.changed-plantuml-files.outputs.modified_files != ''
# Using the docker image directly causes GitHub to try
# to pull the image before docker/login-action runs.
# Because this is a private image, the step would fails when this happens.
run: |
echo Generate SVG diagrams
docker run \
-v ${{ github.workspace }}:/data \
ghcr.io/uclahs-cds/plantuml-github-action:v2.0.0 \
-DPLANTUML_LIMIT_SIZE=8192 \
-v \
-tsvg ${{ steps.changed-plantuml-files.outputs.modified_files }}
- name: Push Local Changes
id: push-changes
if: |
success() && (
steps.changed-plantuml-files.outputs.modified_files != ''
|| steps.changed-plantuml-files.outputs.orphaned_files != '')
uses: stefanzweifel/[email protected]
with:
commit_message: "Update SVG images for PlantUML diagrams"
branch: ${{ github.head_ref }}