Skip to content

Commit 2662883

Browse files
committed
redo package imports and documentation
1 parent 716803d commit 2662883

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

README.md

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
### Import the package
88

99
```python
10-
import pygithubaction.core
10+
from pygithubactions import core
1111
```
1212

1313
### Inputs/Outputs
@@ -17,89 +17,86 @@ Action inputs can be read with `get_input` which returns a `str` or `get_boolean
1717
Outputs can be set with `set_output` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
1818

1919
```python
20-
from pygithubaction.core import get_input
21-
from pygithubaction.core import set_output
20+
from pygithubactions import core
2221

23-
my_input = get_input('inputName', required=True);
24-
boolean_input = get_boolean_input('booleanInputName', required=True);
25-
multiline_input = get_multiline_input('multilineInputName', required=True)
22+
my_input = core.get_input('inputName', required=True)
23+
boolean_input = core.get_boolean_input('booleanInputName', required=True)
24+
multiline_input = core.get_multiline_input('multilineInputName', required=True)
2625

27-
set_output('outputkey', 'outputval')
26+
core.set_output('outputkey', 'outputval')
2827
```
2928

3029
### Exporting variables
3130

3231
Since each step runs in a separate process, you can use `export_variable` to add it to this step and future steps environment blocks.
3332

3433
```python
35-
from pygithubaction.core import export_variable
34+
from pygithubactions import core
3635

37-
export_variable('envvar', 'val')
36+
core.export_variable('envvar', 'val')
3837
```
3938

4039
### Setting a secret
4140

4241
Setting a secret registers the secret with the runner to ensure it is masked in logs.
4342

4443
```python
45-
from pygithubaction.core import set_secret
44+
from pygithubactions import core
4645

47-
set_secret('mypassword')
46+
core.set_secret('mypassword')
4847
```
4948

5049
### PATH Manipulation
5150

5251
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.
5352

5453
```python
55-
from pygithubaction.core import add_path
54+
from pygithubactions import core
5655

57-
add_path('/path/to/mytool')
56+
core.add_path('/path/to/mytool')
5857
```
5958

6059
### Exit codes
6160

6261
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.
6362

6463
```python
65-
from pygithubaction.core import set_failed
64+
from pygithubactions import core
6665

6766
try:
6867
# Do stuff
6968
# ...
7069

7170
except Exception as e:
7271
# 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}')
7473
```
7574

7675
### Logging
7776

7877
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).
7978

8079
```python
81-
from pygithubaction.core import (
82-
get_input, debug, info, notice, is_debug, error
83-
)
80+
from pygithubactions import core
8481

8582

86-
my_input = get_input('input');
83+
my_input = core.get_input('input')
8784

8885
try:
89-
debug('Inside try block')
90-
86+
core.debug('Inside try block')
87+
9188
if not 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+
if core.is_debug():
92+
# do something
9693
else:
97-
# curl https://github.com
94+
# do something
9895

9996
# 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')
10299

103100
except Exception as e:
104-
error(f'Error: {e}, action may still succeed though')
101+
core.error(f'Error: {e}, action may still succeed though')
105102
```

pygithubactions/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pygithubactions.core import core

0 commit comments

Comments
 (0)