diff --git a/source/plugins/core/README.md b/source/plugins/core/README.md index b96d1bb5..b590224a 100644 --- a/source/plugins/core/README.md +++ b/source/plugins/core/README.md @@ -1,8 +1,283 @@ -### ๐Ÿงฑ Core + + + + + + + + + + + + + + + + + +

๐Ÿงฑ Core

Global configuration and options

+
Supported features
โ†’ Full specification
๐Ÿ‘ค Users ๐Ÿ‘ฅ Organizations ๐Ÿ““ Repositories
๐Ÿ—๏ธ token ๐Ÿ—๏ธ committer_token
+ +
+ -Metrics also have general options that impact global metrics rendering. +[โžก๏ธ Jump to all available options](#%EF%B8%8F-available-options) -#### โžก๏ธ Available options +## ๐ŸŒ Configure used timezone + +By default, dates use Greenwich meridian (GMT/UTC). + +Configure `config_timezone` (see [supported timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) to avoid time offsets. + +*Example: configuring timezone* +```yaml +- uses: lowlighter/metrics@latest + with: + config_timezone: Europe/Paris +``` + +## ๐Ÿ“ฆ Ordering content + +Content can be manually ordered using `config_order` option. + +*Example: display base.header, isocalendar, languages and stars in this specific order* +```yaml +- uses: lowlighter/metrics@latest + with: + base: header + plugin_isocalendar: yes + plugin_languages: yes + plugin_stars: yes + config_order: base.header, isocalendar, languages, stars +``` + +> ๐Ÿ’ก Omitted sections will be appended at the end using default order + +## ๐ŸŽจ Custom CSS styling + +Additional CSS can be injected using `extras_css` option. + +*Example: changing the color of `h2`* +```yaml +- uses: lowlighter/metrics@latest + with: + base: header + extras_css: | + h2 { + color: red; + } +``` + +> ๐Ÿ’ก *metrics* does not use `!important` keyword, so use it when having trouble when styling is not applied + +> ๐Ÿ’ก If you make an heavy use of this option, creating a [community templates](/source/templates/community/README.md) may be a better alternative + +> โš ๏ธ CSS styles may slightly change between releases, backward compatibility is not guaranteed! + +## โ†”๏ธ Controlling display size + +Some templates may support different output display size. + +A `regular` display size will render a medium-sized image suitable for both desktop and mobile displays, while a `large` one will be more suitable only for desktop and some plugins (like [`๐Ÿ“Œ topics`](/source/plugins/topics/README.md) or [`๐Ÿ… contributors`](/source/plugins/contributors/README.md)) + +The `columns` display will render a full-width image with automatic resizing: two columns for desktop and a single one column for mobiles. + +*Example: output a PNG image* +```yaml +- uses: lowlighter/metrics@latest + with: + config_display: large +``` + +## ๐Ÿ’ฑ Configuring output format + +Use `config_output` to change output format. + +*Example: output a PNG image* +```yaml +- uses: lowlighter/metrics@latest + with: + config_output: png +``` + +A JSON output can be used to retrieved collected data and use it elsewhere. + +*Example: output a JSON data dump* +```yaml +- uses: lowlighter/metrics@latest + with: + config_output: json +``` + +When using a PDF output, it is advised to set `config_base64: yes` to encode embed images in base64 in order to make self-contained documents. + +*Example: output a self-contained PDF document* +```yaml +- uses: lowlighter/metrics@latest + with: + markdown: TEMPLATE.md + config_output: markdown-pdf + config_base64: yes +``` + +## โœจ Render `Metrics insights` statically + +It is possible to generate a self-contained HTML file containing `โœจ Metrics insights` output by using `config_output: insights`. + +> ๐Ÿ’ก Note that like `โœจ Metrics insights` content is not configurable, thus any other plugin option will actually be ignored + +*Example: output `โœจ Metrics insights` report* +```yaml +- uses: lowlighter/metrics@latest + with: + config_output: insights +``` + +## ๐Ÿงถ Configuring output action + +### Using commits (default) + +Use `config_output: commit` to make the action directly push changes to `committer_branch` with a commit. +A custom commit message can be used through `committer_message`. + +> ๐Ÿ’ก *metrics* will automatically ignore push events with a commit message containing `[Skip GitHub Action]` or `Auto-generated metrics for run #` to avoid infinite loops. Note that by default, GitHub already ignore events pushed by `${{ github.token }}` or containing `[skip ci]` in commit message + +*Example: push output to metrics-renders branch rather than the default branch* +```yaml +- uses: lowlighter/metrics@latest + with: + output_action: commit + committer_branch: metrics-renders + committer_message: "chore: update metrics" +``` + +### Using pull requests + +Use `config_output: pull-request` to make the action open a new pull request and push changes from the same run on it. + +The last step should use either `pull-request-merge`, `pull-request-squash` or `pull-request-rebase` to merge changes to `committer_branch`. + +> ๐Ÿ’ก When using `pull-request` output action, do not forget to change `filename` too or previous output will be overwritten! + +*Example: push two outputs using a merge pull request* +```yaml +- uses: lowlighter/metrics@latest + with: + filename: my-metrics-0.svg + output_action: pull-request + +- uses: lowlighter/metrics@latest + with: + filename: my-metrics-1.svg + output_action: pull-request-merge +``` + +### Using gists + +Use `config_output: gist` to push output to a [GitHub gist](https://gist.github.com) instead. +It is required to provide a gist id to `committer_gist` option to make it work. + +> ๐Ÿ’ก This feature will use `token` instead of `committer_token` to push changes, so `gists` scope must be granted to the original `token` first + +*Example: push output to a gist* +```yaml +- uses: lowlighter/metrics@latest + with: + output_action: gist + committer_gist: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +``` + +### Manual handling + +Use `config_ouput: none` to perform custom processing with outputs. +They will be available under `/metrics_renders/{filename}` in the runner. + +*Example: generate outputs and manually push them* +```yaml +- name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + +- uses: lowlighter/metrics@latest + with: + output_action: none + +- uses: lowlighter/metrics@latest + run: | + set +e + git checkout metrics-renders + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + sudo mv /metrics_renders/* ./ + git add --all + git commit -m "chore: push metrics" + git push +``` + +## โ™ป๏ธ Retrying automatically failed rendering and output action + +Rendering is subject to external factors and can fail ocassionaly. +Use `retries` and `retries_delay` options to automatically retry rendering. + +*Example: retry render up to 3 times (wait 5 minutes between each fail)* +```yaml +- uses: lowlighter/metrics@latest + with: + retries: 3 + retries_delay: 300 +``` + +Output action is also subject to GitHub API rate-limiting and overall health status and can fail ocassionaly. +Use `retries_output_action` and `retries_delay_output_action` options to automatically retry output action. + +> ๐Ÿ’ก As output action is a separate step from rendering, render step won't be called again + +*Example: retry output action up to 5 times (wait 2 minutes between each fail)* +```yaml +- uses: lowlighter/metrics@latest + with: + retries_output_action: 5 + retries_delay_output_action: 120 +``` + +## ๐Ÿ—œ๏ธ Optimize SVG output + +To reduce filesize and decrease loading time, *metrics* offers several optimization options, such as purging unused CSS and style minification, XML pretty-pretting (which also reduce diffs between changes) and general SVG optimation (still experimental). + +> ๐Ÿ’ก This option is enabled by default! + +*Example: optimize CSS and XML* +```yaml +- uses: lowlighter/metrics@latest + with: + optimize: css, xml +``` + +*Example: optimize SVG (experimental)* +```yaml +- uses: lowlighter/metrics@latest + with: + optimize: svg + experimental_features: --optimize-svg +``` + +## ๐Ÿณ Faster execution with prebuilt docker images + +When using `lowlighter/metrics` official releases as a GitHub Action, a prebuilt docker container image will be pulled from [GitHub Container Registry](https://github.com/users/lowlighter/packages/container/package/metrics). It allows to significantly reduce workflow execution time. + +> ๐Ÿ’ก This option is enabled by default! + +On forks, this feature is disable to take into account any changes you made on it. + +*Example: using prebuilt docker image* +```yaml +- uses: lowlighter/metrics@latest + with: + use_prebuilt_image: yes +``` + +## โžก๏ธ Available options @@ -11,7 +286,9 @@ Metrics also have general options that impact global metrics rendering. - @@ -23,6 +300,7 @@ Metrics also have general options that impact global metrics rendering. @@ -32,6 +310,7 @@ Metrics also have general options that impact global metrics rendering. @@ -41,6 +320,10 @@ Metrics also have general options that impact global metrics rendering. @@ -51,7 +334,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -61,6 +345,7 @@ Metrics also have general options that impact global metrics rendering. @@ -70,7 +355,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -79,7 +365,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -89,7 +376,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -99,7 +387,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -110,6 +398,18 @@ Metrics also have general options that impact global metrics rendering. @@ -121,17 +421,25 @@ Metrics also have general options that impact global metrics rendering. - + - @@ -143,7 +451,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -154,7 +463,9 @@ Metrics also have general options that impact global metrics rendering. - @@ -164,7 +475,12 @@ Metrics also have general options that impact global metrics rendering. - @@ -175,6 +491,8 @@ Metrics also have general options that impact global metrics rendering. @@ -184,7 +502,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -194,7 +513,10 @@ Metrics also have general options that impact global metrics rendering. - @@ -205,7 +527,9 @@ Metrics also have general options that impact global metrics rendering. - @@ -217,6 +541,9 @@ Metrics also have general options that impact global metrics rendering. @@ -227,7 +554,15 @@ Metrics also have general options that impact global metrics rendering. - @@ -239,7 +574,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -250,7 +585,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -261,7 +597,21 @@ Metrics also have general options that impact global metrics rendering. - @@ -271,7 +621,17 @@ Metrics also have general options that impact global metrics rendering. - @@ -282,7 +642,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -295,7 +655,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -308,7 +668,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -321,7 +681,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -334,7 +694,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -347,17 +708,21 @@ Metrics also have general options that impact global metrics rendering. - - - @@ -368,7 +733,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -379,7 +745,7 @@ Metrics also have general options that impact global metrics rendering. - @@ -391,6 +757,12 @@ Metrics also have general options that impact global metrics rendering. @@ -402,7 +774,8 @@ Metrics also have general options that impact global metrics rendering. - @@ -414,6 +787,7 @@ Metrics also have general options that impact global metrics rendering. @@ -435,342 +809,4 @@ Metrics also have general options that impact global metrics rendering. default: no
token

GitHub Personal Token

+

GitHub Personal Access Token

+

No scopes are required by default, though some plugins and features may require additional scopes

+

When using a configuration which does not requires a GitHub PAT, you may pass NOT_NEEDED instead

user

GitHub username

+

Defaults to token owner username.

repo

GitHub repository

+

This option is revevalant only for repositories templates

committer_token

GitHub Token used to commit metrics

+

Leave this to ${{ github.token }} or ${{ secrets.GITHUB_TOKEN }}, which is a special auto-generated token restricted to current repository scope.

+
+

๐Ÿ’ก When using output_action: gist, it will use token instead, since gists are outside of scope

+
committer_branch

Branch used to commit rendered metrics

+

Target branch

+

Default value is set to your repository default branch

committer_message

Commit message

+

Use ${filename} to display filename

committer_gist

Gist used to store metrics

+

Gist id

+

Specify an existing gist id (can be retrieved from its URL) when using output_action: gist.

filename

Rendered metrics output path

+

Output path

+

When using an asterisk (*), correct extension will automatically be applied according to config_output value

markdown

Rendered markdown output path

+

Markdown template path

+

It can be either a local path or a full link (e.g. https://raw.githubusercontent.com)

markdown_cache

Rendered markdown file cache

+

Markdown file cache

output_action

Output action

+
    +
  • none: just create file in /metrics_renders directory of action runner
  • +
  • commit: push output to committer_branch
  • +
  • pull-request: push output to a new branch and open a pull request to committer_branch
  • +
  • pull-request-merge: same as pull-request and additionaly merge pull request
  • +
  • pull-request-squash: same as pull-request and additionaly squash and merge pull request
  • +
  • pull-request-rebase: same as pull-request and additionaly rebase and merge pull request
  • +
  • gist: push output to committer_gist
  • +
+
+

๐Ÿ’ก When using pull-request, you will need to set the last job with a pull-request-* action instead, else it won't be merged

+
output_condition

Output condition

+
    +
  • always: always try to push changes
  • +
  • data-changed: skip changes if no data changed (e.g. like when only metadata changed)
  • +
type: string -
-default: always
-allowed values:
  • always
  • data-changed
type: undefined +
optimize

SVG optimization

+

Optimization features

+
    +
  • css: purge and minify CSS styles
  • +
  • xml: pretty-print XML (useful to reduce diff)
  • +
  • svg: optimization with SVGO (experimental, require --optimize-svg experimental flag)
  • +
+

Some templates may not support all options

setup_community_templates

Additional community templates to setup

+

Community templates to setup

+

See community templates guide for more informations

template

Template to use

+

Template

+

Community templates must be prefixed by at sign (@) +See list of supported templates

query

Additional query parameters

+

Query parameters

+

Pass additional parameters to templates. +This is mostly useful for custom templates.

+
+

โš ๏ธ Do not use this option to pass other existing parameters, they will be overwritten

+
extras_css

Extra CSS

+

Custom CSS that will be injected in used template. +Useful to avoid creating a new template just to tweak some styling

config_timezone

Timezone used

+

Timezone for dates

+

See list of supported timezone

config_order

Configure content order

+

Plugin order

+

By default, templates use partials/_.json ordering. +You can override the content order by using this setting.

+

If some partials are omitted, they will be appended at the end with default ordering

config_twemoji

Use twemojis instead of emojis

+

Use twemojis

+

Replace emojis by twemojis to have a consistent render across all platforms +May increase filesize.

config_gemoji

Use GitHub custom emojis

+

GitHub supports additional emojis which are not registered in Unicode standard (:octocat:, :shipit:, :trollface:, ...) +See full list at https://api.github.com/emojis.

+

May increase filesize

config_display

Render display width

+

Display width (for image output formats)

+
    +
  • regular: 480px width
  • +
  • large: 960px width (may not be supported by all templates)
  • +
  • columns: Full width with auto-sizing (two columns for desktops, and one column for mobile) +
  • +
config_animations

SVG CSS animations

+

Use CSS animations

config_base64

Encode images links into base64 data

+

Base64-encoded images

+

Enable this option to make self-contained ouput (i.e. with no external links)

config_padding

Image padding

+

Output padding

+

Although metrics try to auto-guess resulting height, rendering is still dependent on OS and browser settings. +It can result in cropped or oversized outputs.

+

This settings let you manually adjust padding with the following format:

+
    +
  • 1 value for both width and height
  • +
  • 2 values for width fist and height second, separated by a comma (,)
  • +
+

Each value need to respect the following format:

+
    +
  • {number}
  • +
  • {number} + {number}%
  • +
  • {number}%
  • +
+

Percentage are relative to computed dimensions

config_output

Output image format

+

Output format

+
    +
  • auto: Template default (usually svg or markdown)
  • +
  • svg: SVG image
  • +
  • png: PNG image (animations not supported)
  • +
  • jpeg: JPEG image (animations and transparency not supported)
  • +
  • json: JSON data dump
  • +
  • markdown: Markdown rendered file
  • +
  • markdown-pdf: PDF from markdown rendered file
  • +
  • insights: Metrics Insights self-contained HTML file (not configurable)
  • +
retries

Number of retries

+

Retries in case of failures (for rendering)

retries_delay

Time to wait (in seconds) before each retry

+

Delay between each retry (in seconds, for rendering)

retries_output_action

Number of retries (output action)

+

Retries in case of failures (for output action)

retries_delay_output_action

Time to wait (in seconds) before each retry (output action)

+

Delay between each retry (in seconds, for output action)

delay

Use this to avoid triggering abuse mechanics on large workflows

+

Job delay

+

This can be used to avoid triggering GitHub abuse mechanics on large workflows

use_prebuilt_image

Use pre-built image from GitHub registry

+

Use pre-built docker image from GitHub container registry

+

It allows to save build time and make job significantly faster, and there is almost no reason to disable this settings. +This option has no effects on forks (images will always be rebuilt from Dockerfile)

type: boolean + ๐Ÿ”ง For development
+type: boolean
default: yes
plugins_errors_fatal

Die on plugins errors

+

Fatal plugin errors

+

When enabled, the job will fail in case of plugin errors, else it will be handled gracefully in output with an error message

debug

Debug logs

+

Debug mode

+

This setting is automatically enable if a job fail (useful with plugins_errors_fatal: yes)

verify

Verify SVG

+

SVG validity check

debug_flags

Debug flags

+
    +
  • --cakeday: simulate registration anniversary
  • +
  • --hireable: simulate "Available for hire" account setting
  • +
  • --halloween: enable halloween colors
  • +
  • --error: force render error
  • +
dryrun

Enable dry-run

+

Dry-run

+

Contrary to output_action: none, output file won't be available in /metrics_renders directory

experimental_features

Experimental features

+

No backward compatibility is guaranteed for these features

- - -*[โ†’ Full specification](metadata.yml)* - -### ๐Ÿ› ๏ธ General configuration - -A GitHub personal access token is required in `token` option. -It cannot be `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}` as these are special tokens scoped to a single repository, so metrics would not be able to fetch any user related data or external repositories informations. - -By default, metrics will be generated for the user who owns the `token`, but it is possible to generate them for another user or an organization using `user` option. Additional scopes may be required to do so. - -To generate metrics for a repository, use `user` option to specify the repository owner, and `repo` option to specify its name. - -Committer options lets you specify how to rendered metrics should be pushed. -Usually leaving default values is fine, but you have the possibility to change which user will commit to repository using `committer_token`, on which branch using `committer_branch` and with a specific commit message using `committer_message`. - -You may also be interested in using [pull requests](/source/plugins/core#-using-commits-pull-requests-or-manual-review-to-handle-metrics-output) instead of commits. - -When generating multiple metrics, you'll need to save them under different `filename`s to avoid them being overwritten at each step. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - token: ${{ secrets.METRICS_TOKEN }} - user: lowlighter - repo: metrics - committer_token: ${{ github.token }} - committer_branch: my-branch - committer_message: Update metrics - filename: metrics.svg - # ... other options -``` - -### ๐Ÿ–ผ๏ธ Templates configuration - -To use a different template, pass its identifier to `template` option. -See the [list of supported templates](/source/templates/README.md). - -It is possible to use templates from any forked repositories (not necessarly your own) while using official releases using [community templates](/source/templates/community/README.md). - -Some templates may accept additional custom options that you can pass through the `query` option, using a JSON formatted string. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - template: "@super-metrics" - setup_community_templates: octocat/metrics@master:super-metrics, octocat/metrics@master:trusted-metrics+trust - query: '{"custom_color":"#FF0000"}' -``` - -### ๐ŸŽจ Custom CSS styling - -You can inject CSS rules using `extras_css` option. - -If you make heavy use of this option, consider using [community templates](/source/templates/community/README.md) instead. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - base: header - extras_css: | - h2 { - color: red; - } -``` - -### ๐ŸŒ Set timezone - -By default, dates are based on Greenwich meridian (GMT/UTC). - -Set your timezone (see [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) for a list of supported timezones) using `config_timezone` option. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_timezone: Europe/Paris -``` - -### ๐Ÿ“ฆ Ordering content - -You can order metrics content by using `config_order` option. - -It is not mandatory to specify all partials of used templates. -Omitted one will be appended using default order. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - base: header - plugin_isocalendar: yes - plugin_languages: yes - plugin_stars: yes - config_order: base.header, isocalendar, languages, stars -``` - -### ๐Ÿฅณ Render GitHub custom emojis - -GitHub provide additional emojis which are not registered in Unicode standard (:octocat:, :shipit:, :trollface:, ...). -You can choose to render (or not) [GitHub emojis](https://github.com/github/gemoji). - -It may increase filesize since it replace special strings by base64 images. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_gemoji: yes -``` - -### ๐Ÿ™‚ Using twemojis instead of emojis - -You can choose to use [twemojis](https://github.com/twitter/twemoji) instead of regular emojis so rendered metrics are more consistent across all platforms. - -It may increase filesize since it replace unicode characters by SVG images. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_twemoji: yes -``` - -### โ†”๏ธ Controlling display size - -Some templates like `classic` and `repositories` support different output display size: -- `regular` (default) will render a medium-sized image, which is suitable for both desktop and mobile displays and is preferable when using data-intensive metrics (since text may be scaled down on small devices) -- `large` will render a large-sized image, which may be more suitable for some plugins (like displaying topics icons, repository contributors, etc.) -- `columns` will render a full-width image, with two columns on desktop / one column on mobile - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_display: large -``` - -### ๐ŸŽž๏ธ SVG CSS Animations - -As rendered metrics use HTML and CSS, some templates have animations. -You can choose to disable them by using `config_animations` option. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - committer_branch: my-branch -``` - -### ๐Ÿ”ฒ Adjust padding - -Height of rendered metrics is computed after being rendered through an headless browser. -As it can depend on fonts and operating system, it is possible that final result is cropped or has blank space at the bottom. - -You can adjust padding by using `config_padding` option. - -Specify a single value to apply it to both height and with, and two values to use the first one for width and the second for height. Both positive and negative values are accepted. - -The allowed format is `(absolute padding) + (relative padding)%` (each operand is optional). - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_padding: 0, 8 + 11% # 0px width padding, 8px + 11% height padding -``` - -### ๐Ÿงถ Using commits, pull requests, manual reviews or gists to handle metrics output - -It is possible to configure output behaviour using `output_action` option, which can be set to: -- `none`, where output will be generated in `/rendered/${filename}` without being pushed - - You can then manually post-process it -- `commit` (default), where output will directly be committed and pushed to `committer_branch` -- `pull-request`, where output will be committed to a new branch with current run id waiting for to be merged in `committer_branch` - - By appending either `-merge`, `-squash` or `-rebase`, pull request will be automatically merged with given method - - This method is useful to combine all editions of a single run with multiples metrics steps into a single commit on targetted branch - - If you choose to manually merge pull requests, be sure to disable `push:` triggers on your workflow, as it'll count as your own commit -- `gist`, where output will be stored an already existing gist - - To use this feature, a `gists` scope must be granted to your `token` and `committer_gist` identifier must be provided - -It also possible to alter output condition using `output_condition` option, which can be set to: -- `always`, to always push changes (provided that git sha changed) -- `data-changed`, to skip changes if no actual data changed (e.g. when only render timestamp changed) - -#### โ„น๏ธ Examples workflows - -```yaml -# The following will: -# - open a pull request with "my-metrics-0.svg" as first commit -# - append "my-metrics-1.svg" as second commit -# - merge pull request (as second step is set to "pull-request-merge") - -- uses: lowlighter/metrics@latest - with: - # ... other options - filename: my-metrics-0.svg - output_action: pull-request - -- uses: lowlighter/metrics@latest - with: - # ... other options - filename: my-metrics-1.svg - output_action: pull-request-merge -``` - -### โ™ป๏ธ Retrying automatically failed rendering and output action - -Rendering is subject to external factors and can fail from time to time. -It is possible to mitigate this issue using `retries` and `retries_delay` options to automatically retry later metrics rendering and avoid workflow fails. - -Output action is also subject to GitHub API rate-limiting and status and can fail from time to time. -It is possible to mitigate this issue using `retries_output_action` and `retries_delay_output_action` options to automatically retry later metrics output action and avoid workflow fails. As this is a separate step from rendering, metrics rendering won't be computed again during this phase. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - retries: 3 - retries_delay: 300 - retries_output_action: 5 - retries_delay_output_action: 120 -``` - -### ๐Ÿ’ฑ Convert output to PNG/JPEG or JSON - -It is possible to convert output from SVG to PNG or JPEG images and even to JSON by using `config_output` option. - -Note that `png` does not support animations while `jpeg` does not support both animations and transparency. - -Using `json` output can be useful if you want to retrieve all data computed by metrics without rendering it. -It could then be processed for other usages. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_output: png -``` - -### ๐Ÿ–จ๏ธ Convert output to PDF - -It is possible to convert output to PDF when using a markdown template by setting `config_output` to `markdown-pdf`. - -It is advised to keep `config_base64: yes` to encode embed images in base64 and make self-contained documents. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - markdown: template.md - markdown_cache: .cache - config_output: markdown-pdf - config_base64: yes -``` - -### ๐Ÿ—œ๏ธ Optimize SVG output - -It is possible to optimize SVG output and reducing its filesize to improve loading times and reduce storage. - -The following optimizations are supported: -- `css`, which purge unused CSS and minify remaining styles -- `xml`, which pretty-print XML (it also helps reducing diffs between commits) -- `svg`, which optimize SVG with SVGO (experimental) - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - optimize: css, xml - -- uses: lowlighter/metrics@latest - with: - # ... other options - optimize: css, xml, svg - experimental_features: --optimize-svg -``` - -### โœจ Render `Metrics insights` statically - -It is possible to generate an HTML file containing `โœจ Metrics insights` output by setting `config_output` to `insights`. Resulting output will already be pre-rendered and not contain any external sources (i.e. no JavaScript and style sheets). - -> Note that like `โœจ Metrics insights` content is not configurable. - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - config_output: insights -``` - -### ๐Ÿณ Faster execution with prebuilt docker images - -If you're using the official release `lowlighter/metrics` as a GitHub Action (either a specific version, `@latest` or `@master`), it'll pull a prebuilt docker container image from [GitHub Container Registry](https://github.com/users/lowlighter/packages/container/package/metrics) which contains already installed dependencies which will cut execution time from ~5 minutes to ~1 minute. - -These are published through this automated [workflow](/.github/workflows/workflow.yml). - -As code is frozen on docker container images, this feature is disabled on forks to take into account any changes you've made on it. In case you wish to use official releases along with a custom template present on your fork, check out [community templates](/source/templates/community/README.md). - -#### โ„น๏ธ Examples workflows - -```yaml -- uses: lowlighter/metrics@latest - with: - # ... other options - use_prebuilt_image: yes -``` + \ No newline at end of file diff --git a/source/plugins/core/metadata.yml b/source/plugins/core/metadata.yml index 726b11ec..9cfbda9a 100644 --- a/source/plugins/core/metadata.yml +++ b/source/plugins/core/metadata.yml @@ -1,5 +1,6 @@ name: "๐Ÿงฑ Core" category: core +description: Global configuration and options supports: - user - organization @@ -7,314 +8,375 @@ supports: scopes: [] inputs: - # User account personal token - # No additional scopes are needed unless you want to include private repositories metrics - # Some plugins may also require additional scopes - # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ - # If you're only using plugins which don't really require a GitHub token, you may pass "NOT_NEEDED" as value token: - description: GitHub Personal Token + description: | + GitHub Personal Access Token + + No scopes are required by default, though some plugins and features may require additional scopes + + When using a configuration which does not requires a GitHub PAT, you may pass `NOT_NEEDED` instead type: token required: true - # GitHub username - # Defaults to "token" owner user: - description: GitHub username + description: | + GitHub username + + Defaults to `token` owner username. type: string default: "" - # GitHub repository - # Compute metrics for a repository instead ("user" being the repository owner) - # Check https://github.com/lowlighter/metrics/blob/master/source/templates/repository/README.md for more informations repo: - description: GitHub repository + description: | + GitHub repository + + This option is revevalant only for repositories templates type: string default: "" - # Set to "${{ github.token }}" or "${{ secrets.GITHUB_TOKEN }}" - # GITHUB_TOKEN is a special auto-generated token restricted to current repository, which is used to push files in it committer_token: - description: GitHub Token used to commit metrics + description: | + GitHub Token used to commit metrics + + Leave this to `${{ github.token }}` or `${{ secrets.GITHUB_TOKEN }}`, which is a special auto-generated token restricted to current repository scope. + + > ๐Ÿ’ก When using `output_action: gist`, it will use `token` instead, since gists are outside of scope type: token default: ${{ github.token }} - # Branch used to commit rendered metrics committer_branch: - description: Branch used to commit rendered metrics - type: string - default: "" # Defaults to your repository default branch + description: | + Target branch - # Commit message - # Use "${filename}" to display filename - committer_message: - description: Commit message - type: string - default: Update ${filename} - [Skip GitHub Action] - - # Instead of saving metrics to a repository, it's possible to save them to a gist to avoid "commits pollution" - # Gist must be created prior and you must pass its identifier in the following option - # Set "gist" in "output_action" to use this option - committer_gist: - description: Gist used to store metrics + Default value is set to your repository default branch + type: string + default: "" + + committer_message: + description: | + Commit message + + Use `${filename}` to display filename + type: string + default: Update ${filename} - [Skip GitHub Action] + + committer_gist: + description: | + Gist id + + Specify an existing gist id (can be retrieved from its URL) when using `output_action: gist`. type: string default: "" - # Rendered metrics output path, relative to repository's root - # When using "*", the correct extension will automatically on "config_output" value filename: - description: Rendered metrics output path + description: | + Output path + + When using an asterisk (`*`), correct extension will automatically be applied according to `config_output` value type: string default: github-metrics.* - # Rendered markdown output path (when using a markdown template) - # It can be either a local path or a link (e.g. raw.githubusercontent.com) markdown: - description: Rendered markdown output path + description: | + Markdown template path + + It can be either a local path or a full link (e.g. https://raw.githubusercontent.com) type: string default: TEMPLATE.md - # Rendered markdown file cache (when using a markdown template) markdown_cache: - description: Rendered markdown file cache + description: Markdown file cache type: string default: .cache - # Output action output_action: - description: Output action + description: | + Output action + - `none`: just create file in `/metrics_renders` directory of action runner + - `commit`: push output to `committer_branch` + - `pull-request`: push output to a new branch and open a pull request to `committer_branch` + - `pull-request-merge`: same as `pull-request` and additionaly merge pull request + - `pull-request-squash`: same as `pull-request` and additionaly squash and merge pull request + - `pull-request-rebase`: same as `pull-request` and additionaly rebase and merge pull request + - `gist`: push output to `committer_gist` + + > ๐Ÿ’ก When using `pull-request`, you will need to set the last job with a `pull-request-*` action instead, else it won't be merged type: string default: commit values: - - none # Only generate file in "/metrics_renders" - - commit # Commit output to "committer_branch" - - pull-request # Commit output to a new branch and open a pull request to "committer_branch" - - pull-request-merge # Same as "pull-request" and additionaly merge pull request - - pull-request-squash # Same as "pull-request" and additionaly squash and merge pull request - - pull-request-rebase # Same as "pull-request" and additionaly rebase and merge pull request - - gist # Save output to "committer_gist" + - none + - commit + - pull-request + - pull-request-merge + - pull-request-squash + - pull-request-rebase + - gist - # Output condition output_condition: - description: Output condition - type: string - default: always - values: - - always # Always push changes - - data-changed # Skip changes if no actual data changed (e.g. when only render timestamp changed) + description: | + Output condition + - `always`: always try to push changes + - `data-changed`: skip changes if no data changed (e.g. like when only metadata changed) - # Optimize SVG image to reduce its filesize - # Some templates may not support this option optimize: - description: SVG optimization + description: | + Optimization features + - `css`: purge and minify CSS styles + - `xml`: pretty-print XML (useful to reduce diff) + - `svg`: optimization with SVGO (experimental, require `--optimize-svg` experimental flag) + + Some templates may not support all options type: array default: css, xml format: - comma-separated values: - - css # Purge and minify CSS styles - - xml # Pretty-print XML - - svg # Optimize SVG with SVGO (experimental, require --optimize-svg flag) + - css + - xml + - svg # Setup additional templates from remote repositories setup_community_templates: - description: Additional community templates to setup + description: | + Community templates to setup + + See [community templates guide](https://github.com/lowlighter/metrics/blob/master/source/templates/community/README.md) for more informations type: array - format: - - comma-separated - - /(?[-a-z0-9]+)[/](?[-a-z0-9]+)@(?[-a-z0-9]+):(?