@@ -10,6 +10,7 @@ A GitHub Action that automatically creates beautiful coverage reports in pull re
1010- 🔄 ** Smart Updates** : Updates existing comments instead of creating duplicates
1111- 🎨 ** Visual Indicators** : Uses emojis to quickly identify coverage status
1212- 🏷️ ** Coverage Badges** : Generates shields.io compatible badges for GitHub Pages
13+ - 🚀 ** Automatic GitHub Pages Upload** : Automatically uploads badges to GitHub Pages
1314- ⚡ ** Lightweight** : Fast execution with minimal dependencies
1415
1516## Usage
5657
5758permissions :
5859 pull-requests : write
60+ contents : write # Required for GitHub Pages upload
5961
6062jobs :
6163 coverage :
@@ -82,18 +84,24 @@ jobs:
8284 show-files : " true"
8385 coverage-threshold : " 90"
8486 make-badges : " true"
87+ upload-badges-to-pages : " true"
88+ pages-branch : " gh-pages"
89+ pages-badges-dir : " badges"
8590` ` `
8691
8792## Inputs
8893
89- | Input | Description | Required | Default |
90- | -------------------- | --------------------------------------------------------- | -------- | -------------------------------- |
91- | ` coverage-file` | Path to the coverage summary JSON file | No | `coverage/coverage-summary.json` |
92- | `token` | GitHub token for creating comments | No | `${{ github.token }}` |
93- | `title` | Title for the coverage report comment | No | `📊 Coverage Report` |
94- | `show-files` | Whether to show individual file coverage details | No | `true` |
95- | `coverage-threshold` | Minimum coverage percentage to consider as good (0-100) | No | `80` |
96- | `make-badges` | Whether to generate coverage badges in a badges directory | No | `true` |
94+ | Input | Description | Required | Default |
95+ | ------------------------ | --------------------------------------------------------- | -------- | -------------------------------- |
96+ | ` coverage-file` | Path to the coverage summary JSON file | No | `coverage/coverage-summary.json` |
97+ | `token` | GitHub token for creating comments | No | `${{ github.token }}` |
98+ | `title` | Title for the coverage report comment | No | `📊 Coverage Report` |
99+ | `show-files` | Whether to show individual file coverage details | No | `true` |
100+ | `coverage-threshold` | Minimum coverage percentage to consider as good (0-100) | No | `80` |
101+ | `make-badges` | Whether to generate coverage badges in a badges directory | No | `true` |
102+ | `upload-badges-to-pages` | Whether to automatically upload badges to GitHub Pages | No | `true` |
103+ | `pages-branch` | Branch to upload badges to for GitHub Pages | No | `gh-pages` |
104+ | `pages-badges-dir` | Directory within the pages branch to store badges | No | `badges` |
97105
98106# # Coverage File Format
99107
@@ -208,26 +216,44 @@ When `make-badges` is enabled (default: `true`), the action creates a `badges` d
208216
209217### Using Badges with GitHub Pages
210218
211- 1 . Enable GitHub Pages in your repository settings
212- 2 . Set the source to "Deploy from a branch" and select your main branch
213- 3 . The badges will be available at:
219+ The action automatically uploads badges to your GitHub Pages branch when ` upload-badges-to-pages ` is enabled (default: ` true ` ).
220+
221+ 1 . ** Automatic Setup** : The action will:
222+
223+ - Create the ` gh-pages ` branch if it doesn't exist
224+ - Upload badges to the specified directory
225+ - Commit and push changes automatically
226+
227+ 2 . ** Enable GitHub Pages** in your repository settings:
228+
229+ - Go to Settings → Pages
230+ - Set source to "Deploy from a branch"
231+ - Select your ` gh-pages ` branch (or the branch specified in ` pages-branch ` )
232+ - Set folder to ` / (root) ` or ` /badges ` depending on your preference
233+
234+ 3 . ** Badge URLs** will be available at:
214235
215236 ```
216237 https://yourusername.github.io/yourrepo/badges/coverage.json
238+ https://yourusername.github.io/yourrepo/badges/statements.json
239+ https://yourusername.github.io/yourrepo/badges/branches.json
240+ https://yourusername.github.io/yourrepo/badges/functions.json
241+ https://yourusername.github.io/yourrepo/badges/lines.json
217242 ```
218243
219- 4 . Use in your README.md:
244+ 4 . ** Use in your README.md** :
220245 ``` markdown
221246 
247+ 
248+ 
222249 ```
223250
224- ### Example Badge JSON
251+ ### Required Permissions
225252
226- ``` json
227- {
228- "schemaVersion" : 1 ,
229- "label" : " coverage" ,
230- "message" : " 89.8%" ,
231- "color" : " green"
232- }
253+ For automatic GitHub Pages upload, your workflow needs:
254+
255+ ``` yaml
256+ permissions :
257+ pull-requests : write
258+ contents : write # Required for uploading to GitHub Pages
233259` ` `
0 commit comments