Skip to content

Commit fd05611

Browse files
feat: add vars context (#12)
1 parent 5bdb063 commit fd05611

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
env:
2626
EXAMPLE_VAR: 'Value'
2727
with:
28+
vars_context: ${{ toJson(vars) }}
2829
secrets_context: ${{ toJson(secrets) }}
2930
needs_context: ${{ toJson(needs) }}
3031

@@ -40,6 +41,7 @@ jobs:
4041
env:
4142
EXAMPLE_VAR: 'Value'
4243
with:
44+
vars_context: ${{ toJson(vars) }}
4345
secrets_context: ${{ toJson(secrets) }}
4446
needs_context: ${{ toJson(needs) }}
4547

@@ -56,6 +58,7 @@ jobs:
5658
EXAMPLE_VAR: 'Value'
5759
with:
5860
contexts: 'env'
61+
vars_context: ${{ toJson(vars) }}
5962
secrets_context: ${{ toJson(secrets) }}
6063
needs_context: ${{ toJson(needs) }}
6164

@@ -72,6 +75,7 @@ jobs:
7275
EXAMPLE_VAR: 'Value'
7376
with:
7477
contexts: 'github,env'
78+
vars_context: ${{ toJson(vars) }}
7579
secrets_context: ${{ toJson(secrets) }}
7680
needs_context: ${{ toJson(needs) }}
7781

@@ -84,6 +88,7 @@ jobs:
8488
context:
8589
- github
8690
- env
91+
- vars
8792
- job
8893
- steps
8994
- runner
@@ -101,5 +106,6 @@ jobs:
101106
EXAMPLE_VAR: 'Value'
102107
with:
103108
contexts: ${{ matrix.context }}
109+
vars_context: ${{ toJson(vars) }}
104110
secrets_context: ${{ toJson(secrets) }}
105111
needs_context: ${{ toJson(needs) }}

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ This action prints actions contexts for debugging
77
with:
88
# Optional
99
# Specify which contexts to print
10-
# Default: 'github,env,job,steps,runner,secrets,strategy,matrix,needs,inputs'
10+
# Default: 'github,env,vars,job,steps,runner,secrets,strategy,matrix,needs,inputs'
1111
contexts: ''
1212

13+
# Optional
14+
# Provide vars context to action, as vars context is not available in composite workflows
15+
# Default: null
16+
vars_context: ${{ toJson(vars) }}
17+
1318
# Optional
1419
# Provide secrets context to action, as secrets context is not available in composite workflows
1520
# Default: null
@@ -45,6 +50,7 @@ job:
4550
context:
4651
- github
4752
- env
53+
- vars
4854
- job
4955
- steps
5056
- runner
@@ -57,6 +63,7 @@ job:
5763
- uses: henrygriffiths/debug_action@v1
5864
with:
5965
contexts: ${{ matrix.context }}
66+
vars_context: ${{ toJson(vars) }}
6067
secrets_context: ${{ toJson(secrets) }}
6168
needs_context: ${{ toJson(needs) }}
6269
```

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ inputs:
99
contexts:
1010
description: 'Contexts to dump'
1111
required: false
12-
default: 'github,env,job,steps,runner,secrets,strategy,matrix,needs,inputs'
12+
default: 'github,env,vars,job,steps,runner,secrets,strategy,matrix,needs,inputs'
13+
vars_context:
14+
description: 'Vars Context'
15+
required: false
16+
default: 'Vars Context not provided'
1317
secrets_context:
1418
description: 'Secrets Context'
1519
required: false
@@ -26,6 +30,7 @@ runs:
2630
env:
2731
GITHUB_CONTEXT: ${{ toJson(github) }}
2832
ENV_CONTEXT: ${{ toJson(env) }}
33+
VARS_CONTEXT: ${{ inputs.vars_context }}
2934
JOB_CONTEXT: ${{ toJson(job) }}
3035
STEPS_CONTEXT: ${{ toJson(steps) }}
3136
RUNNER_CONTEXT: ${{ toJson(runner) }}

debug_action.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ do
1616
echo -e "\033[1;33m>>>>>> Env Context\033[0m"
1717
echo -e "$ENV_CONTEXT"
1818
echo -e "\033[1;33m<<<<<< Env Context\033[0m"
19+
elif [ $x == 'vars' ]; then
20+
echo -e "\033[1;33m>>>>>> Vars Context\033[0m"
21+
echo -e "$VARS_CONTEXT"
22+
echo -e "\033[1;33m<<<<<< Vars Context\033[0m"
1923
elif [ $x == 'job' ]; then
2024
echo -e "\033[1;33m>>>>>> Job Context\033[0m"
2125
echo -e "$JOB_CONTEXT"

0 commit comments

Comments
 (0)