Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action output for using the error message #65

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,63 @@ as both runs will use separate caches, but providing the shared key will lead to
with:
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:
branches:
- main

jobs:
check-semver:
name: Check semver
runs-on: ubuntu-latest
outputs:
error_message: ${{ steps.check_semver.outputs.error_message }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run cargo-semver-checks
id: check_semver
uses: obi1kenobi/cargo-semver-checks-action@v2

comment-on-pr:
name: Comment on pull request
runs-on: ubuntu-latest
needs: check-semver
if: always()
permissions:
pull-requests: write
Comment on lines +219 to +220
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting! Does this work correctly even if the PR comes from a fork of the repo? 👀

I would have assumed this might give the job "PR write" permissions on the fork, but admittedly I find the GitHub Actions permissions model confusing and unpredictable even after working with it for years.

Copy link
Sponsor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I find it confusing as well. I need to find some time to set up a repo to test this - running out of time now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you get a chance to test this, I'd love to make sure it works well before we put it in the docs.

Copy link
Sponsor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it doesn't work from a fork.

Error: Resource not accessible by integration

Any idea?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never got a chance to dig too deep into this, but last time I looked, one possible answer seemed to be something like "create a GitHub App." That seemed a bit annoying to do, so I didn't do it at the time.

If you find or hear about any other possible workarounds, I'd love to know about them.

Copy link
Sponsor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Well, I'm not sure then. Creating a GitHub app definitely sounds annoying :D

steps:
- name: Comment
if: ${{ needs.check-semver.outputs.error_message != null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-semver-check-error
message: |
Thank you for opening this pull request!

Reviewer note: [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks) reported the current version number is not SemVer-compatible with the changes made since the last release.

Details:

```
${{ needs.check-semver.outputs.error_message }}
```

- name: Delete comment
if: ${{ needs.check-semver.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-semver-check-error
delete: true
```
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,19 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ansi-regex
MIT
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


asynckit
MIT
The MIT License (MIT)
Expand Down Expand Up @@ -1515,6 +1528,19 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


strip-ansi
MIT
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


supports-color
MIT
MIT License
Expand Down
Loading