Skip to content

Commit 1bbf721

Browse files
authored
Merge pull request #10 from saadmk11/docs-update
Rearrange Documentation Sections
2 parents e1d86a2 + 9469513 commit 1bbf721

File tree

1 file changed

+78
-79
lines changed

1 file changed

+78
-79
lines changed

README.md

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,84 @@ Install `github-action-utils` using pip:
2222
```console
2323
pip install github-action-utils
2424
```
25+
## Example
26+
27+
### Example Code
28+
29+
```python
30+
import github_action_utils as gha_utils
31+
32+
with gha_utils.group("My Group"):
33+
gha_utils.set_output("test_var", "test_value")
34+
gha_utils.save_state("state", "val")
35+
36+
gha_utils.debug("Debug message")
37+
38+
gha_utils.warning(
39+
"Warning message", title="Warning Title", file="example.py",
40+
col=1, end_column=2, line=5, end_line=6,
41+
)
42+
gha_utils.warning("Another warning message")
43+
44+
gha_utils.error(
45+
"Error message", title="Error Title", file="example.py",
46+
col=1, end_column=2, line=1, end_line=2,
47+
)
48+
gha_utils.notice("Another notice message")
49+
50+
gha_utils.append_job_summary("# Hello World")
51+
gha_utils.append_job_summary("- Point 1")
52+
gha_utils.append_job_summary("- Point 2")
53+
```
54+
55+
### Can be used inside a Workflow
56+
57+
```yaml
58+
name: run-python-script
59+
60+
on:
61+
pull_request:
62+
branches: [ "main" ]
63+
64+
jobs:
65+
build:
66+
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- uses: actions/checkout@v3
71+
72+
- name: Set up Python 3.10
73+
uses: actions/setup-python@v3
74+
with:
75+
python-version: "3.10"
76+
77+
- name: Install dependencies
78+
run: python -m pip install github-action-utils
79+
80+
- name: Run Python Script
81+
shell: python
82+
run: |
83+
import github_action_utils as gha_utils
84+
85+
with gha_utils.group("My Group"):
86+
gha_utils.error(
87+
"Error message", title="Error Title", file="example.py",
88+
col=1, end_column=2, line=1, end_line=2,
89+
)
90+
gha_utils.notice("Another notice message")
91+
gha_utils.append_job_summary("# Hello World")
92+
```
93+
94+
#### Colorful Grouped Build Log Output
95+
![s3](https://user-images.githubusercontent.com/24854406/180003937-5839856e-09f9-47e7-8b62-f5126a78cad6.png)
96+
97+
#### Log Annotations and Build Summery
98+
![s2](https://user-images.githubusercontent.com/24854406/180003153-99434824-d08c-4a54-9a89-4c6163def1b2.png)
99+
100+
#### Log Annotations Associated with a File
101+
![s](https://user-images.githubusercontent.com/24854406/180003164-12735d03-a452-4bef-96a6-f1dc4298756e.png)
102+
25103
26104
## Available Functions
27105
@@ -392,85 +470,6 @@ More details: [GitHub Actions Event Payload](https://docs.github.com/en/develope
392470
# {"action": "opened", "number": 1, "pull_request": {"url": "https://api.github.com/repos/octocat/Hello-World/pulls/1"}, "repository": {"url": "https://api.github.com/repos/octocat/Hello-World"}, "sender": {"login": "octocat"}...}
393471
```
394472

395-
## Example
396-
397-
### Example Workflow
398-
399-
```yaml
400-
name: run-python-script
401-
402-
on:
403-
pull_request:
404-
branches: [ "main" ]
405-
406-
jobs:
407-
build:
408-
409-
runs-on: ubuntu-latest
410-
411-
steps:
412-
- uses: actions/checkout@v3
413-
414-
- name: Set up Python 3.10
415-
uses: actions/setup-python@v3
416-
with:
417-
python-version: "3.10"
418-
419-
- name: Install dependencies
420-
run: python -m pip install github-action-utils
421-
422-
- name: Run Python Script
423-
shell: python
424-
run: |
425-
import github_action_utils as gha_utils
426-
427-
with gha_utils.group("My Group"):
428-
gha_utils.error(
429-
"Error message", title="Error Title", file="example.py",
430-
col=1, end_column=2, line=1, end_line=2,
431-
)
432-
gha_utils.notice("Another notice message")
433-
gha_utils.append_job_summary("# Hello World")
434-
```
435-
436-
### Example Code
437-
438-
```python
439-
import github_action_utils as gha_utils
440-
441-
with gha_utils.group("My Group"):
442-
gha_utils.set_output("test_var", "test_value")
443-
gha_utils.save_state("state", "val")
444-
445-
gha_utils.debug("Debug message")
446-
447-
gha_utils.warning(
448-
"Warning message", title="Warning Title", file="example.py",
449-
col=1, end_column=2, line=5, end_line=6,
450-
)
451-
gha_utils.warning("Another warning message")
452-
453-
gha_utils.error(
454-
"Error message", title="Error Title", file="example.py",
455-
col=1, end_column=2, line=1, end_line=2,
456-
)
457-
gha_utils.notice("Another notice message")
458-
459-
gha_utils.append_job_summary("# Hello World")
460-
gha_utils.append_job_summary("- Point 1")
461-
gha_utils.append_job_summary("- Point 2")
462-
```
463-
464-
#### Colorful Grouped Build Log Output
465-
![s3](https://user-images.githubusercontent.com/24854406/180003937-5839856e-09f9-47e7-8b62-f5126a78cad6.png)
466-
467-
#### Log Annotations and Build Summery
468-
![s2](https://user-images.githubusercontent.com/24854406/180003153-99434824-d08c-4a54-9a89-4c6163def1b2.png)
469-
470-
#### Log Annotations Associated with a File
471-
![s](https://user-images.githubusercontent.com/24854406/180003164-12735d03-a452-4bef-96a6-f1dc4298756e.png)
472-
473-
474473
# License
475474

476475
The code in this project is released under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)