mirror of
https://github.com/obi1kenobi/cargo-semver-checks-action.git
synced 2024-11-29 11:29:32 +01:00
Add action output for using the error message
This commit is contained in:
parent
48f4ef7da6
commit
e14ddc395d
2 changed files with 51 additions and 1 deletions
48
README.md
48
README.md
|
@ -182,3 +182,51 @@ as both runs will use separate caches, but providing the shared key will lead to
|
||||||
with:
|
with:
|
||||||
prefix-key: v1
|
prefix-key: v1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Using the error message as output
|
||||||
|
|
||||||
|
In case the semver check fails, this action will populate the `error_message` output.
|
||||||
|
|
||||||
|
[An output can be used in other steps](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs), for example to comment the error message onto the pull request.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
name: "Check PR"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- edited
|
||||||
|
- synchronize
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
name: Check semver
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Run cargo-semver-checks
|
||||||
|
id: check_semver
|
||||||
|
uses: obi1kenobi/cargo-semver-checks-action@v2
|
||||||
|
|
||||||
|
- uses: marocchino/sticky-pull-request-comment@v2
|
||||||
|
# When the previous steps fails, the workflow would stop. By adding this
|
||||||
|
# condition you can continue the execution with the populated error message.
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
header: pr-semver-check-error
|
||||||
|
message: |
|
||||||
|
Thank you for opening this pull request!
|
||||||
|
|
||||||
|
There seems to be semver incompatibility issues reported by [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks).
|
||||||
|
|
||||||
|
Details:
|
||||||
|
|
||||||
|
> ${{ steps.check_semver.outputs.error_message }}
|
||||||
|
|
||||||
|
# Delete a previous comment when the issue has been resolved
|
||||||
|
- if: ${{ steps.check_semver.outputs.error_message == null }}
|
||||||
|
uses: marocchino/sticky-pull-request-comment@v2
|
||||||
|
with:
|
||||||
|
header: pr-semver-check-error
|
||||||
|
delete: true
|
||||||
|
```
|
||||||
|
|
|
@ -168,7 +168,9 @@ async function main() {
|
||||||
try {
|
try {
|
||||||
await run();
|
await run();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(getErrorMessage(error));
|
const error_message = getErrorMessage(error);
|
||||||
|
core.setOutput("error_message", error_message);
|
||||||
|
core.setFailed(error_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue