-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
76 lines (69 loc) · 2.58 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
name: 'Markdown Summary Template'
description: 'Add custom step summaries to your workflows with ease. No more 200 lines of "echo ... >> $GITHUB_STEP_SUMMARY"'
branding:
icon: align-center
color: gray-dark
inputs:
template:
required: true
description: |
Your markdown template. Write as if it was normal markdown.
For JetBrains users, add `# language="markdown"` to the line above to get nice syntax highlighting.
step-output-only:
default: 'false'
description: |
Whether to only emit the template to GitHub step output instead of adding it directly to the step summary
Useful if you want to feed the template into some other workflow step.
variables:
required: false
description: |
A list of environment variables to inject into your markdown template.
For example;
...
variables: >-
FOO="bar"
SOMEONE="world"
template: |
# Hello, $SOMEONE
This is $FOO
outputs:
parsed:
value: ${{ steps.template.outputs.parsed }}
description: |
Parsed output of your template.
Useful if you want to feed the template into some other workflow step.
input:
value: ${{ steps.template.outputs.input }}
description: |
Your raw template before it was parsed.
variables:
value: ${{ steps.template.outputs.variables }}
description: |
The input variables you provided to build the template. Handy if you need to re-use them somewhere else.
runs:
using: "composite"
steps:
- name: 'Build template'
id: template
shell: bash
env:
TEMPLATE: ${{ inputs.template }}
STEP_OUTPUT_ONLY: ${{ inputs.step-output-only }}
# language="bashpro shell script"
run: |
parsed_template="$(echo "$TEMPLATE" | ${{ inputs.variables }} envsubst)"
emitToOutput() {
local key="$1"
local value="$2"
local EOF="EOF-$key-$RANDOM"
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
echo "$key<<$EOF" >> $GITHUB_OUTPUT
echo "$value" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
}
if [[ "$STEP_OUTPUT_ONLY" != "true" ]]; then
echo "$parsed_template" >> $GITHUB_STEP_SUMMARY || exit 1
fi
emitToOutput parsed "$parsed_template" || exit 1
emitToOutput input "$TEMPLATE" || exit 1
emitToOutput variables "${{ inputs.variables }}" || exit 1