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

chore: explaning fork limitations #54

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/* linguist-generated
21 changes: 21 additions & 0 deletions .github/workflows/summary-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: example of summary
on:
pull_request:

jobs:
build:
name: example of workflow
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master

- name: clover file to comment (clover.example.base.xml)
uses: ./.
with:
dir-prefix: /var/www/html
file: clover.example.base.xml
base-file: clover.example.xml
chart-size: 75
only-with-cover: true
signature: "summary example"
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- explanation about forks and token permissions with them.
- new option `skip-comments-on-forks` to prevent blocking pull requests from forks because of lack of
permissions.

### Changed

- improving error reporting for debugging purposes

## [0.12.0] - 2024-02-02

### Added
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Configuration
| `table-coverage-change` | Show only files which their coverage changed equal or above this percentage <br/> Default: `0` |
| `signature` | Custom signature to be used at the bottom of the comment. <br/>If you need multiple comments per pull request each step needs to have a unique `signature` |
| `github-token` | Custom [PAT][pat] to be used instead of the [default action token][default-token], should have the `repo` scope |
| `skip-comments-on-forks` | Should skip trying to comment on [pull requests created from forks](#restrictions-on-forks) <br/> Default: `false` |

Example usage
-------------
Expand Down Expand Up @@ -155,10 +156,25 @@ jobs:
base-file: tests/base/coverage.xml
```

Restrictions on Forks
---------------------

Github Actions [imposes higher Restrictions on workflows triggered from forks in public repositories][fork],
where the default token generated will have only read permissions.

Because of that when this Action is run on pull requests from forks no comment will be created with the
coverage report, instead the report will only be shown at the steps summary.

![example of step summary with the report](./assets/summary-example.png)

If comments on pull request from forks are required for your workflow a [PAT](pat) can be used, but be aware
that doing that may open the owner of the PAT to the malicious intentions of the internet.

[CHANGELOG](CHANGELOG.md)
---------

[danhunsaker/clover-reporter-action]: https://github.com/danhunsaker/clover-reporter-action
[pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
[lang]: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Intl#argumento_locales
[default-token]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
[fork]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ inputs:
signature:
description: Custom signature to be used at the bottom of the comment
required: false
skip-comments-on-forks:
description: Should skip trying to comment on pull requests created from forks
default: false

runs:
using: node20
main: bin/index.js
Binary file added assets/summary-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 69 additions & 33 deletions bin/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/index.js.map

Large diffs are not rendered by default.

Loading
Loading