-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
60 lines (59 loc) · 2.32 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
name: 'Print Workflow Dispatch Inputs'
description: 'A GitHub Action that prints all workflow_dispatch input values and optionally environment variables to the log. optionally can add inputs to the GitHub Summary in a collapsible format.'
inputs:
print_env_vars:
description: 'Whether to print environment variables'
required: false
default: 'false'
add_to_summary:
description: 'Whether to add inputs to GitHub Summary'
required: false
default: 'false'
outputs:
output:
description: 'The output of the action'
value: ${{ steps.set-output.outputs.action_output }}
branding:
icon: 'printer'
color: 'blue'
runs:
using: "composite"
steps:
- name: Print workflow_dispatch inputs and env vars
id: set-output
shell: bash
env:
PRINT_ENV_VARS: ${{ inputs.print_env_vars }}
ADD_TO_SUMMARY: ${{ inputs.add_to_summary }}
run: |
output=$(
echo "Checking for workflow_dispatch inputs:"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
if [ -n "$GITHUB_EVENT_PATH" ] && [ -f "$GITHUB_EVENT_PATH" ]; then
inputs=$(jq -r '.inputs // empty' "$GITHUB_EVENT_PATH")
if [ -n "$inputs" ] && [ "$inputs" != "null" ]; then
echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"'
if [ "$ADD_TO_SUMMARY" = "true" ]; then
echo -e "\n<details>\n<summary>Inputs</summary>\n\n\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"' >> $GITHUB_STEP_SUMMARY
echo -e "\`\`\`\n</details>" >> $GITHUB_STEP_SUMMARY
fi
else
echo "No workflow_dispatch inputs found in the event payload."
fi
else
echo "GITHUB_EVENT_PATH is not set or the file does not exist."
fi
else
echo "This is not a workflow_dispatch event. No inputs expected."
fi
if [ "$PRINT_ENV_VARS" = "true" ]; then
echo -e "\nPrinting environment variables:"
env | sort
fi
)
echo "$output"
output="${output//'%'/'%25'}"
output="${output//$'\n'/'%0A'}"
output="${output//$'\r'/'%0D'}"
echo "action_output=$output" >> $GITHUB_OUTPUT