@@ -22,6 +22,84 @@ Install `github-action-utils` using pip:
2222``` console
2323pip 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+ 
96+
97+ #### Log Annotations and Build Summery
98+ 
99+
100+ #### Log Annotations Associated with a File
101+ 
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- 
466-
467- #### Log Annotations and Build Summery
468- 
469-
470- #### Log Annotations Associated with a File
471- 
472-
473-
474473# License
475474
476475The code in this project is released under the [MIT License](LICENSE).
0 commit comments