You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since each step runs in a separate process, you can use `export_variable` to add it to this step and future steps environment blocks.
33
32
34
33
```python
35
-
frompygithubaction.coreimportexport_variable
34
+
frompygithubactionsimportcore
36
35
37
-
export_variable('envvar', 'val')
36
+
core.export_variable('envvar', 'val')
38
37
```
39
38
40
39
### Setting a secret
41
40
42
41
Setting a secret registers the secret with the runner to ensure it is masked in logs.
43
42
44
43
```python
45
-
frompygithubaction.coreimportset_secret
44
+
frompygithubactionsimportcore
46
45
47
-
set_secret('mypassword')
46
+
core.set_secret('mypassword')
48
47
```
49
48
50
49
### PATH Manipulation
51
50
52
51
To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `add_path`. The runner will prepend the path given to the jobs PATH.
53
52
54
53
```python
55
-
frompygithubaction.coreimportadd_path
54
+
frompygithubactionsimportcore
56
55
57
-
add_path('/path/to/mytool')
56
+
core.add_path('/path/to/mytool')
58
57
```
59
58
60
59
### Exit codes
61
60
62
61
You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success.
63
62
64
63
```python
65
-
frompygithubaction.coreimportset_failed
64
+
frompygithubactionsimportcore
66
65
67
66
try:
68
67
# Do stuff
69
68
# ...
70
69
71
70
exceptExceptionas e:
72
71
# set_failed logs the message and sets a failing exit code
73
-
set_failed(f'Action failed with error {e}')
72
+
core.set_failed(f'Action failed with error {e}')
74
73
```
75
74
76
75
### Logging
77
76
78
77
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
79
78
80
79
```python
81
-
from pygithubaction.core import (
82
-
get_input, debug, info, notice, is_debug, error
83
-
)
80
+
from pygithubactions import core
84
81
85
82
86
-
my_input = get_input('input');
83
+
my_input =core.get_input('input')
87
84
88
85
try:
89
-
debug('Inside try block')
90
-
86
+
core.debug('Inside try block')
87
+
91
88
ifnot my_input:
92
-
warning('my_input was not set')
93
-
94
-
if is_debug():
95
-
#curl -v https://github.com
89
+
core.warning('my_input was not set')
90
+
91
+
ifcore.is_debug():
92
+
#do something
96
93
else:
97
-
#curl https://github.com
94
+
#do something
98
95
99
96
# Do stuff
100
-
info('Output to the actions build log')
101
-
notice('This is a message that will also emit an annotation')
97
+
core.info('Output to the actions build log')
98
+
core.notice('This is a message that will also emit an annotation')
102
99
103
100
exceptExceptionas e:
104
-
error(f'Error: {e}, action may still succeed though')
101
+
core.error(f'Error: {e}, action may still succeed though')
0 commit comments