Skip to content

Commit 8761e42

Browse files
authored
Merge pull request #31 from aj3sh/actions-error-msg
feat: added error annotation on github actions
2 parents d6301f1 + 830de67 commit 8761e42

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

.github/workflows/test_action.yaml

+1-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Commitlint
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches: ['main']
66
pull_request:
77

88
jobs:
@@ -13,20 +13,6 @@ jobs:
1313
- uses: actions/checkout@v4
1414

1515
- name: Run commitlint
16-
id: commitlintrun
1716
uses: ./ # Uses an action in the root directory
1817
# or use a released GitHub Action
1918
# uses: opensource-nepal/[email protected]
20-
with:
21-
fail_on_error: false
22-
23-
- name: Check Output
24-
run: |
25-
echo 'Status - ${{ steps.commitlintrun.outputs.status }}'
26-
echo 'Exit Code - ${{ steps.commitlintrun.outputs.exit_code }}'
27-
28-
# Check commitlintrun status
29-
if [ "${{ steps.commitlintrun.outputs.status }}" = "failure" ]; then
30-
echo "Failing the job manually because Commitlint status is failure."
31-
exit 1
32-
fi

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ commitlint is a tool designed to lint your commit messages according to the [Con
3939
If you have any existing workflows, add the following steps:
4040

4141
```yaml
42+
...
4243
steps:
4344
...
4445
- name: Run commitlint
@@ -71,17 +72,16 @@ jobs:
7172
7273
#### GitHub Action Inputs
7374
74-
| # | Name | Type | Default | Description |
75-
| --- | ----------------- | -----------| -----------| ----------- |
76-
| 1 | **fail_on_error** | Boolean | true | Determines whether the GitHub Action should fail when encountering an error. |
77-
75+
| # | Name | Type | Default | Description |
76+
| --- | ----------------- | ------- | ------- | --------------------------------------------------------------------- |
77+
| 1 | **fail_on_error** | Boolean | true | Determines whether the GitHub Action should fail if commitlint fails. |
7878
7979
#### GitHub Action Outputs
8080
81-
| # | Name | Type | Description |
82-
| --- | -------------- | --------------| ------------ |
83-
| 1 | **exit_code** | Integer | The exit code indicating the success or failure of the GitHub Actions workflow. |
84-
| 2 | **status** |'failure' \| 'success'| The status of the GitHub Actions workflow, indicating success or failure. |
81+
| # | Name | Type | Description |
82+
| --- | ------------- | ------- | ---------------------------------------------------------------------------- |
83+
| 1 | **exit_code** | Integer | The exit code of the commitlint step. |
84+
| 2 | **status** | String | The outcome of the commitlint step. Possible values: 'success' or 'failure'. |
8585
8686
## Contribution
8787

github_actions/run.py

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def _check_commits(from_hash: str, to_hash: str) -> None:
152152
_write_output("exit_code", 0)
153153

154154
except subprocess.CalledProcessError as error:
155+
sys.stderr.write("::error::Commit validation failed!\n")
155156
_write_output("status", STATUS_FAILURE)
156157
_write_output("exit_code", error.returncode)
157158
val = _get_input(INPUT_FAIL_ON_ERROR)

0 commit comments

Comments
 (0)