Skip to content

Commit b19e2cd

Browse files
committed
DumpEnvironment: Add additional contexts
1 parent 8f43ee3 commit b19e2cd

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

DumpEnvironmentAction/action.yml

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ inputs:
88
required: false
99
type: string
1010
default: '{}'
11+
jobs:
12+
required: false
13+
type: string
14+
default: '{}'
15+
needs:
16+
required: false
17+
type: string
18+
default: '{}'
1119
save_output:
1220
type: boolean
1321
default: false
@@ -30,33 +38,63 @@ runs:
3038
mkdir ${OUTPUT_DIR}
3139
set +e +v +x
3240
echo "::group::inputs"
33-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/inputs.json
41+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/inputs.json
3442
${{toJSON(fromJSON(inputs.action-inputs))}}
3543
%%EOF%%
3644
echo "::endgroup::"
3745
38-
echo "::group::vars"
39-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/vars.json
46+
echo "::group::action_vars"
47+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/action_vars.json
4048
${{toJSON(fromJSON(inputs.action-vars))}}
4149
%%EOF%%
4250
echo "::endgroup::"
4351
44-
echo "::group::ctxenv"
45-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/job.env
46-
${{toJSON(env)}}
52+
echo "::group::jobs_context"
53+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/jobs_context.json
54+
${{toJSON(fromJSON(inputs.jobs))}}
4755
%%EOF%%
4856
echo "::endgroup::"
49-
50-
echo "::group::env"
51-
printenv | sort | tee ${OUTPUT_DIR}/workflow.env
57+
58+
echo "::group::needs_context"
59+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/needs_context.json
60+
${{toJSON(fromJSON(inputs.needs))}}
61+
%%EOF%%
62+
echo "::endgroup::"
63+
64+
echo "::group::env_context"
65+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/env_context.json
66+
${{toJSON(env)}}
67+
%%EOF%%
5268
echo "::endgroup::"
5369
5470
echo "::group::github_context"
55-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/context.json
71+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/github_context.json
5672
${{toJSON(github)}}
5773
%%EOF%%
5874
echo "::endgroup::"
5975
76+
echo "::group::job_context"
77+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/job_context.json
78+
${{toJSON(job)}}
79+
%%EOF%%
80+
echo "::endgroup::"
81+
82+
echo "::group::runner_context"
83+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/runner_context.json
84+
${{toJSON(runner)}}
85+
%%EOF%%
86+
echo "::endgroup::"
87+
88+
echo "::group::steps_context"
89+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/steps_context.json
90+
${{toJSON(steps)}}
91+
%%EOF%%
92+
echo "::endgroup::"
93+
94+
echo "::group::shell_env"
95+
printenv | sort | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/shell_env.env
96+
echo "::endgroup::"
97+
6098
echo "::group::GITHUB_WORKSPCE: ${GITHUB_WORKSPACE}"
6199
echo "${GITHUB_WORKSPACE}" > ${OUTPUT_DIR}/GITHUB_WORKSPACE.txt
62100
ls -al ${GITHUB_WORKSPACE} | tee -a ${OUTPUT_DIR}/GITHUB_WORKSPACE.txt
@@ -82,7 +120,7 @@ runs:
82120
83121
- name: Save Output
84122
id: save-output
85-
if: ${{ inputs.save_output }}
123+
if: ${{ fromJSON(inputs.save_output) }}
86124
uses: actions/upload-artifact@v4
87125
with:
88126
name: ${{inputs.artifact_id}}

0 commit comments

Comments
 (0)