-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
82 lines (76 loc) · 3.05 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Local PlantUML run
description: Run plantuml using locally downloaded jar file
inputs:
version:
description: Plantuml version to use
default: latest
required: false
cache-plantuml-jar:
description: >
Cache the downloaded plantuml.jar
[ignored if version is specified as 'latest']
default: 'true'
required: false
cli-arguments:
description: CLI arguments for plantuml
default: '-h'
required: false
jvm-options:
description: Options for the JVM
default: ''
required: false
runs:
using: composite
steps:
# To make this action OS-agnostic, we need to explicitly compute the install path
# and shell for the following reasons:
# 1. The Windows directory separator (backslash \) is treated as escape character
# in bash, which rules out(*) using bash in Windows runs.
# 2. Composite actions does not support a default shell: https://github.com/actions/runner/blob/fb6d1adb430a6c96407c5857854a40662af439c8/docs/adrs/1144-composite-actions.md#defaults---not-being-considered-at-this-time
#
# (*) By enclosing the entire path in single quotes, the backslash can be preserved
# in bash, but this feels to me like an ugly and unintuitive workaround.
- name: Compute OS-specific config
id: os-specific-config
shell: bash
run: |
if [ '${{ runner.os }}' != 'Windows' ]; then
echo "install-path=${{ runner.temp }}/plantuml.jar" >> "$GITHUB_OUTPUT"
echo "shell=bash" >> "$GITHUB_OUTPUT"
else
echo "install-path=${{ runner.temp }}\plantuml.jar" >> "$GITHUB_OUTPUT"
echo "shell=pwsh" >> "$GITHUB_OUTPUT"
fi
- name: Load cached plantuml
id: cached-plantuml
if: ${{ inputs.cache-plantuml-jar == 'true' && inputs.version != 'latest' }}
uses: actions/cache@v4.0.2
with:
path: ${{ steps.os-specific-config.outputs.install-path }}
key: plantuml-jar-${{ runner.os }}-${{ inputs.version }}
- name: Compute plantuml source path
id: plantuml-source-path
if: steps.cached-plantuml.outputs.cache-hit != 'true'
shell: bash
run: |
PLANTUML_RELEASES_BASE_URL=https://github.com/plantuml/plantuml/releases/
if [ '${{ inputs.version }}' = 'latest' ]; then
PLANTUML_DOWNLOAD_PATH=latest/download/plantuml.jar
else
PLANTUML_DOWNLOAD_PATH=download/v${{ inputs.version }}/plantuml.jar
fi
echo "value=$PLANTUML_RELEASES_BASE_URL/$PLANTUML_DOWNLOAD_PATH" \
>> "$GITHUB_OUTPUT"
- name: Install plantuml
if: steps.cached-plantuml.outputs.cache-hit != 'true'
shell: ${{ steps.os-specific-config.outputs.shell }}
run: >
curl -Ls
-o ${{ steps.os-specific-config.outputs.install-path }}
${{ steps.plantuml-source-path.outputs.value }}
- name: Run plantuml
shell: ${{ steps.os-specific-config.outputs.shell }}
run: >
java ${{ inputs.jvm-options }}
-jar ${{ steps.os-specific-config.outputs.install-path }}
${{ inputs.cli-arguments }}