1+ # https://help.github.com/en/articles/metadata-syntax-for-github-actions
2+ name : ' Dump context'
3+ description : ' GitHub Action composite to dump context'
4+ author : ' crazy-max'
5+ branding :
6+ color : ' yellow'
7+ icon : ' activity'
8+
9+ runs :
10+ using : " composite"
11+ steps :
12+ -
13+ uses : actions/github-script@v6
14+ with :
15+ script : |
16+ const fs = require('fs');
17+
18+ await core.group(`Env vars`, async () => {
19+ const envs = Object.keys(process.env).sort().reduce(
20+ (obj, key) => {
21+ obj[key] = process.env[key];
22+ return obj;
23+ }, {}
24+ );
25+ core.info(JSON.stringify(Object.fromEntries(Object.entries(envs).filter(([key]) => !key.startsWith('GHACTION_DCTX_') && !key.startsWith('INPUT_'))), null, 2));
26+ });
27+
28+ await core.group(`GitHub context`, async () => {
29+ core.info(JSON.stringify(JSON.parse(`${process.env.GHACTION_DCTX_GITHUB_CONTEXT}`), null, 2));
30+ });
31+ await core.group(`Job context`, async () => {
32+ core.info(JSON.stringify(JSON.parse(`${process.env.GHACTION_DCTX_JOB_CONTEXT}`), null, 2));
33+ });
34+ await core.group(`Steps context`, async () => {
35+ core.info(JSON.stringify(JSON.parse(`${process.env.GHACTION_DCTX_STEPS_CONTEXT}`), null, 2));
36+ });
37+ await core.group(`Runner context`, async () => {
38+ core.info(JSON.stringify(JSON.parse(`${process.env.GHACTION_DCTX_RUNNER_CONTEXT}`), null, 2));
39+ });
40+ await core.group(`Strategy context`, async () => {
41+ core.info(JSON.stringify(JSON.parse(`${process.env.GHACTION_DCTX_STRATEGY_CONTEXT}`), null, 2));
42+ });
43+ await core.group(`Matrix context`, async () => {
44+ core.info(JSON.stringify(JSON.parse(`${process.env.GHACTION_DCTX_MATRIX_CONTEXT}`), null, 2));
45+ });
46+
47+ await core.group(`Docker info`, async () => {
48+ await exec.exec('docker', ['info'], {ignoreReturnCode: true}).catch(error => {
49+ core.info(error);
50+ });
51+ });
52+ await core.group(`Docker version`, async () => {
53+ await exec.exec('docker', ['version'], {ignoreReturnCode: true}).catch(error => {
54+ core.info(error);
55+ });
56+ });
57+ await core.group(`Docker images`, async () => {
58+ await exec.exec('docker', ['image', 'ls'], {ignoreReturnCode: true}).catch(error => {
59+ core.info(error);
60+ });
61+ });
62+
63+ if (`${process.env.RUNNER_OS}` == 'Linux') {
64+ await core.group(`Install deps`, async () => {
65+ const sudo = await exec.getExecOutput('which sudo', [], {silent: true, ignoreReturnCode: true})
66+ if (sudo.stdout != "") {
67+ const aptget = await exec.getExecOutput('which apt-get', [], {silent: true, ignoreReturnCode: true})
68+ if (aptget.stdout != "") {
69+ await exec.exec('sudo apt-get update');
70+ await exec.exec('sudo apt-get install -y cgroup-tools cpuid');
71+ } else {
72+ core.info('apt-get not found; not installing deps')
73+ }
74+ } else {
75+ core.info('sudo not found; not installing deps')
76+ }
77+ });
78+ await core.group(`Print cpuinfo`, async () => {
79+ await exec.exec('cat /proc/cpuinfo');
80+ });
81+ await core.group(`Print cpuid`, async () => {
82+ const cpuid = await exec.getExecOutput('which cpuid', [], {silent: true, ignoreReturnCode: true})
83+ if (cpuid.stdout != "") {
84+ await exec.exec('cpuid');
85+ } else {
86+ core.info('cpuid not found')
87+ }
88+ });
89+ await core.group(`File system`, async () => {
90+ await exec.exec('df -ah');
91+ });
92+ await core.group(`Mounts`, async () => {
93+ await exec.exec('mount');
94+ });
95+ await core.group(`Docker daemon conf`, async () => {
96+ if ((fs.statSync('/etc/docker', {throwIfNoEntry: false}) != undefined) &&
97+ (fs.statSync('/etc/docker/daemon.json', {throwIfNoEntry: false}) != undefined)) {
98+ core.info(JSON.stringify(JSON.parse(fs.readFileSync('/etc/docker/daemon.json', {encoding: 'utf-8'}).trim()), null, 2));
99+ } else {
100+ core.info('/etc/docker/daemon.json not present')
101+ }
102+ });
103+ await core.group(`Cgroups`, async () => {
104+ const lscgroup = await exec.getExecOutput('which lscgroup', [], {silent: true, ignoreReturnCode: true})
105+ if (lscgroup.stdout != "") {
106+ await exec.exec('lscgroup');
107+ } else {
108+ core.info('lscgroup not found')
109+ }
110+ });
111+ await core.group(`containerd version`, async () => {
112+ const containerd = await exec.getExecOutput('which containerd', [], {silent: true, ignoreReturnCode: true})
113+ if (containerd.stdout != "") {
114+ await exec.exec('containerd --version');
115+ } else {
116+ core.info('containerd not found')
117+ }
118+ });
119+ }
120+ env :
121+ GHACTION_DCTX_GITHUB_CONTEXT : ${{ toJson(github) }}
122+ GHACTION_DCTX_JOB_CONTEXT : ${{ toJson(job) }}
123+ GHACTION_DCTX_STEPS_CONTEXT : ${{ toJson(steps) }}
124+ GHACTION_DCTX_RUNNER_CONTEXT : ${{ toJson(runner) }}
125+ GHACTION_DCTX_STRATEGY_CONTEXT : ${{ toJson(strategy) }}
126+ GHACTION_DCTX_MATRIX_CONTEXT : ${{ toJson(matrix) }}
0 commit comments