Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 78 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,84 @@ Install `github-action-utils` using pip:
```console
pip install github-action-utils
```
## Example

### Example Code

```python
import github_action_utils as gha_utils

with gha_utils.group("My Group"):
gha_utils.set_output("test_var", "test_value")
gha_utils.save_state("state", "val")

gha_utils.debug("Debug message")

gha_utils.warning(
"Warning message", title="Warning Title", file="example.py",
col=1, end_column=2, line=5, end_line=6,
)
gha_utils.warning("Another warning message")

gha_utils.error(
"Error message", title="Error Title", file="example.py",
col=1, end_column=2, line=1, end_line=2,
)
gha_utils.notice("Another notice message")

gha_utils.append_job_summary("# Hello World")
gha_utils.append_job_summary("- Point 1")
gha_utils.append_job_summary("- Point 2")
```

### Can be used inside a Workflow

```yaml
name: run-python-script

on:
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: python -m pip install github-action-utils

- name: Run Python Script
shell: python
run: |
import github_action_utils as gha_utils

with gha_utils.group("My Group"):
gha_utils.error(
"Error message", title="Error Title", file="example.py",
col=1, end_column=2, line=1, end_line=2,
)
gha_utils.notice("Another notice message")
gha_utils.append_job_summary("# Hello World")
```

#### Colorful Grouped Build Log Output
![s3](https://user-images.githubusercontent.com/24854406/180003937-5839856e-09f9-47e7-8b62-f5126a78cad6.png)

#### Log Annotations and Build Summery
![s2](https://user-images.githubusercontent.com/24854406/180003153-99434824-d08c-4a54-9a89-4c6163def1b2.png)

#### Log Annotations Associated with a File
![s](https://user-images.githubusercontent.com/24854406/180003164-12735d03-a452-4bef-96a6-f1dc4298756e.png)


## Available Functions

Expand Down Expand Up @@ -392,85 +470,6 @@ More details: [GitHub Actions Event Payload](https://docs.github.com/en/develope
# {"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"}...}
```

## Example

### Example Workflow

```yaml
name: run-python-script

on:
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: python -m pip install github-action-utils

- name: Run Python Script
shell: python
run: |
import github_action_utils as gha_utils

with gha_utils.group("My Group"):
gha_utils.error(
"Error message", title="Error Title", file="example.py",
col=1, end_column=2, line=1, end_line=2,
)
gha_utils.notice("Another notice message")
gha_utils.append_job_summary("# Hello World")
```

### Example Code

```python
import github_action_utils as gha_utils

with gha_utils.group("My Group"):
gha_utils.set_output("test_var", "test_value")
gha_utils.save_state("state", "val")

gha_utils.debug("Debug message")

gha_utils.warning(
"Warning message", title="Warning Title", file="example.py",
col=1, end_column=2, line=5, end_line=6,
)
gha_utils.warning("Another warning message")

gha_utils.error(
"Error message", title="Error Title", file="example.py",
col=1, end_column=2, line=1, end_line=2,
)
gha_utils.notice("Another notice message")

gha_utils.append_job_summary("# Hello World")
gha_utils.append_job_summary("- Point 1")
gha_utils.append_job_summary("- Point 2")
```

#### Colorful Grouped Build Log Output
![s3](https://user-images.githubusercontent.com/24854406/180003937-5839856e-09f9-47e7-8b62-f5126a78cad6.png)

#### Log Annotations and Build Summery
![s2](https://user-images.githubusercontent.com/24854406/180003153-99434824-d08c-4a54-9a89-4c6163def1b2.png)

#### Log Annotations Associated with a File
![s](https://user-images.githubusercontent.com/24854406/180003164-12735d03-a452-4bef-96a6-f1dc4298756e.png)


# License

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