Skip to content

Commit 0ba80d7

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

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

DumpEnvironmentAction/action.yml

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
required: false
99
type: string
1010
default: '{}'
11+
jobs:
12+
required: false
13+
type: string
14+
default: '{}'
1115
save_output:
1216
type: boolean
1317
default: false
@@ -30,33 +34,63 @@ runs:
3034
mkdir ${OUTPUT_DIR}
3135
set +e +v +x
3236
echo "::group::inputs"
33-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/inputs.json
37+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/inputs.json
3438
${{toJSON(fromJSON(inputs.action-inputs))}}
3539
%%EOF%%
3640
echo "::endgroup::"
3741
38-
echo "::group::vars"
39-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/vars.json
42+
echo "::group::action_vars"
43+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/action_vars.json
4044
${{toJSON(fromJSON(inputs.action-vars))}}
4145
%%EOF%%
4246
echo "::endgroup::"
4347
44-
echo "::group::ctxenv"
45-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/job.env
48+
echo "::group::env_context"
49+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/env_context.json
4650
${{toJSON(env)}}
4751
%%EOF%%
4852
echo "::endgroup::"
4953
50-
echo "::group::env"
51-
printenv | sort | tee ${OUTPUT_DIR}/workflow.env
52-
echo "::endgroup::"
53-
5454
echo "::group::github_context"
55-
cat <<%%EOF%% | tee ${OUTPUT_DIR}/context.json
55+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/github_context.json
5656
${{toJSON(github)}}
5757
%%EOF%%
5858
echo "::endgroup::"
5959
60+
echo "::group::job_context"
61+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/job_context.json
62+
${{toJSON(job)}}
63+
%%EOF%%
64+
echo "::endgroup::"
65+
66+
echo "::group::jobs_context"
67+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/jobs_context.json
68+
${{toJSON(fromJSON(inputs.jobs))}}
69+
%%EOF%%
70+
echo "::endgroup::"
71+
72+
echo "::group::runner_context"
73+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/runner_context.json
74+
${{toJSON(runner)}}
75+
%%EOF%%
76+
echo "::endgroup::"
77+
78+
echo "::group::steps_context"
79+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/steps_context.json
80+
${{toJSON(steps)}}
81+
%%EOF%%
82+
echo "::endgroup::"
83+
84+
echo "::group::needs_context"
85+
cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/needs_context.json
86+
${{toJSON(needs)}}
87+
%%EOF%%
88+
echo "::endgroup::"
89+
90+
echo "::group::shell_env"
91+
printenv | sort | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/shell_env.env
92+
echo "::endgroup::"
93+
6094
echo "::group::GITHUB_WORKSPCE: ${GITHUB_WORKSPACE}"
6195
echo "${GITHUB_WORKSPACE}" > ${OUTPUT_DIR}/GITHUB_WORKSPACE.txt
6296
ls -al ${GITHUB_WORKSPACE} | tee -a ${OUTPUT_DIR}/GITHUB_WORKSPACE.txt
@@ -82,7 +116,7 @@ runs:
82116
83117
- name: Save Output
84118
id: save-output
85-
if: ${{ inputs.save_output }}
119+
if: ${{ fromJSON(inputs.save_output) }}
86120
uses: actions/upload-artifact@v4
87121
with:
88122
name: ${{inputs.artifact_id}}

0 commit comments

Comments
 (0)