|
2 | 2 |
|
3 | 3 | Setup a GitHub Action which runs periodically and pushes generated images to a repository. |
4 | 4 |
|
5 | | -Assuming your username is `my-github-user`, you can then embed rendered metrics in your readme like below: |
| 5 | +## 0️ Setup a personal repository |
6 | 6 |
|
7 | | -```markdown |
8 | | -<!-- If you're using "master" as default branch --> |
9 | | - |
10 | | -<!-- If you're using "main" as default branch --> |
11 | | - |
12 | | -``` |
13 | | - |
14 | | -## 💬 How to setup? |
15 | | - |
16 | | -### 0. Setup a personal repository |
17 | | - |
18 | | -Create a repository with the same name as your GitHub login (if it's not already done). |
| 7 | +Create a repository with the same name as your GitHub login (if it doesn't exist). |
19 | 8 |
|
20 | 9 |  |
21 | 10 |
|
22 | 11 | Its `README.md` will be displayed on your user profile: |
23 | 12 |
|
24 | 13 |  |
25 | 14 |
|
26 | | -### 1. Create a GitHub personal token |
| 15 | +## 1️ Create a GitHub personal token |
27 | 16 |
|
28 | 17 | From the `Developer settings` of your account settings, select `Personal access tokens` to create a new token. |
29 | 18 |
|
30 | | -No additional scopes are needed for basic metrics, but you may have to grant additional scope depending on what features you're planning to use: |
31 | | -- `public_repo` scope for some plugins |
32 | | -- `read:org` scope for all organizations related metrics |
33 | | -- `repo` scope for all private repositories related metrics |
34 | | - - `read:user` scope may also be required for some private repositories related metrics |
| 19 | +No scopes are required, but additional one may be required depending on which features will be used. Each plugin documentation enumerates which scopes are required to make it work. |
| 20 | + |
| 21 | +A a general rule, the following scopes may be required: |
| 22 | +- `public_repo` for some plugins |
| 23 | +- `read:org` for all organizations related metrics |
| 24 | +- `repo` for all private repositories related metrics |
| 25 | + - `read:user` for some private repositories related metrics |
| 26 | +- `gist` for publishing renders to gists instead of a repository |
| 27 | + |
| 28 | +> 💡 For security reasons, it is advised to always use the least amount of scopes. It is possible to prevent security issues by [forking this repository](https://github.com/lowlighter/metrics/fork) and using it in your workflow instead (more information available in step 3) |
35 | 29 |
|
36 | 30 |  |
37 | 31 |
|
38 | | -A scope-less token can still display private contributions by enabling `Include private contributions on my profile` in your account settings: |
| 32 | +A scope-less token can still display private contributions by enabling `Include private contributions on my profile` in account settings: |
39 | 33 |
|
40 | 34 |  |
41 | 35 |
|
42 | | -If a plugin has not enough scopes to operate (and `plugins_errors_fatal` isn't enabled), it'll be reported in the rendering like below: |
| 36 | +When a plugin has not enough scopes to operate (and `plugins_errors_fatal` is disabled), an error will be reported in the rendering like below: |
43 | 37 |
|
44 | 38 |  |
45 | 39 |
|
46 | | -### 2. Put your GitHub personal token in your repository secrets |
| 40 | +## 2️ Put your GitHub personal token in repository secrets |
47 | 41 |
|
48 | | -Go to the `Settings` of your repository to create a new secret and paste your freshly generated GitHub token there. |
| 42 | +Go to the `Settings` of your repository and to create a new secret and paste your freshly generated GitHub token there. |
49 | 43 |
|
50 | 44 |  |
51 | 45 |
|
52 | | -### 3. Create a GitHub Action workflow in your repository |
| 46 | +## 3️ Setup GitHub Action workflow |
53 | 47 |
|
54 | | -Create a new workflow from the `Actions` tab of your repository and paste the following: |
| 48 | +Create a new workflow from the `Actions` tab of repository and paste the following: |
55 | 49 |
|
56 | 50 | ```yaml |
57 | 51 | name: Metrics |
58 | 52 | on: |
59 | | - # Schedule updates (each hour) |
60 | | - schedule: [{cron: "0 * * * *"}] |
61 | | - # Lines below let you run workflow manually and on each commit (optional) |
| 53 | + # Schedule daily updates |
| 54 | + schedule: [{cron: "0 0 * * *"}] |
| 55 | + # (optional) Run workflow manually |
62 | 56 | workflow_dispatch: |
| 57 | + # (optional) Run workflow when pushing on master/main |
63 | 58 | push: {branches: ["master", "main"]} |
64 | 59 | jobs: |
65 | 60 | github-metrics: |
66 | 61 | runs-on: ubuntu-latest |
67 | 62 | steps: |
68 | | - # See action.yml for all options |
69 | 63 | - uses: lowlighter/metrics@latest |
70 | 64 | with: |
71 | | - # Your GitHub token |
72 | 65 | token: ${{ secrets.METRICS_TOKEN }} |
73 | 66 | ``` |
74 | 67 |
|
75 | | -See all supported options in [action.yml](/action.yml). |
76 | | -
|
77 | | -Rendered metrics will be committed to your repository on each run. |
| 68 | +Rendered metrics will be committed to repository on each run. |
78 | 69 |
|
79 | 70 |  |
80 | 71 |
|
81 | | -#### Choosing between `@latest`, `@master` or a fork |
| 72 | +### 3️.1️ Choosing between `@latest`, `@master`/`@main`, a fork or a pinned version |
82 | 73 |
|
83 | | -If you wish to use new features as they're being released, you can switch from `@latest` to `@master`. |
84 | | -As the latter is used as a development branch, jobs may fail from time to time (although we try to mitigate this). |
| 74 | +There are several *metrics* versions that can be used in workflows: |
85 | 75 |
|
86 | | -For convenience, it is possible to use `@main` instead of `@master`. |
| 76 | +- `@latest` |
| 77 | + - ✔️ Stable version |
| 78 | +- `@master`/`@main` |
| 79 | + - ✔️ Enjoy new features and bug fixes as they're being released |
| 80 | + - ✔️ Helps discovering new issues |
| 81 | + - ➖ Jobs may fail occasionally (watch [issues](https://github.com/lowlighter/metrics/issues) and [discussions](https://github.com/lowlighter/metrics/discussions) for bug tracking) |
| 82 | +- `@{fork}` |
| 83 | + - ✔️ Secure as you're in control |
| 84 | + - ✔️ Advised when using additional scopes in personal access token |
| 85 | + - ➖ Manual updates (watch new [releases](https://github.com/lowlighter/metrics/releases) for updates) |
| 86 | +- `@v{x}.{x}` |
| 87 | + - ➖ |
87 | 88 |
|
88 | | -When using a token with additional permissions, it is advised to fork this repository and use it instead to minimize security risks: |
| 89 | +> 💡 Workflows are always compatible with previous version as *metrics* workflow-breaking changes are never introduced. In fact, even workflows from v1.0 are still compatible! |
| 90 | + |
| 91 | +*Example: using a forked version* |
89 | 92 | ```yaml |
90 | | - - uses: my-github-username/metrics@master |
91 | | - # If you make changes on your fork, be sure not leave @latest as tag! |
| 93 | + - uses: user/metrics@master |
92 | 94 | ``` |
93 | 95 |
|
94 | | -In this case, please consider watching new releases to stay up-to-date and enjoy latest features! |
| 96 | +> ⚠️ Be sure to use the default branch (`@master`) on forks to apply any changes made! |
95 | 97 |
|
96 | | -`@latest` will be updated on each release. Metrics doesn't introduce breaking changes **from an user point of view** (i.e. your workflows will always be valid) so you can follow release cycles without worrying. |
| 98 | +### 3️.2️ Configure *metrics* |
97 | 99 |
|
98 | | -#### Examples workflows |
| 100 | +Read [documentation](/README.md#-documentation) for more informations about configuration. |
| 101 | +It is advised to start with [`🧱 core`](/source/plugins/core/README.md) plugin documentation. |
99 | 102 |
|
100 | | -Metrics displayed on this page are rendered from this [workflow](https://github.com/lowlighter/metrics/blob/examples/.github/workflows/metrics.yml) so you can check it out for some code examples about plugins usage. |
| 103 | +It is also possible to use [metrics.lecoq.io](https://metrics.lecoq.io) to play with configuration options, preview renders and finally copy the auto-generated workflow code. |
101 | 104 |
|
102 | | -You can also take a look at this [user workflow](https://github.com/lowlighter/metrics/blob/examples/.github/workflows/personal.yml) if you want. |
| 105 | +## 4️ Add images to your profile `README.md` |
103 | 106 |
|
104 | | -### 4. Embed link into your README.md |
| 107 | +Update profile `README.md` to include rendered image (filename may differ if `filename` option has been set, use the correct path accordingly). |
105 | 108 |
|
106 | | -Update your README.md to embed your metrics: |
| 109 | +*Example: add rendered image with markdown* |
| 110 | +```markdown |
| 111 | + |
| 112 | +``` |
107 | 113 |
|
| 114 | +*Example: add rendered image with html for more customization* |
108 | 115 | ```markdown |
109 | | -<!-- If you're using "master" as default branch --> |
110 | | - |
111 | | -<!-- If you're using "main" as default branch --> |
112 | | - |
113 | | -<!-- If you're using the "columns" display mode --> |
114 | | -<img src="https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg" alt="Metrics" width="100%"> |
115 | | -``` |
| 116 | +<img align="center" src="/github-metrics.svg" width="400"> |
| 117 | +``` |
| 118 | + |
| 119 | +*Example: add rendered image when using `config_display: columns`* |
| 120 | +```markdown |
| 121 | +<img src="/github-metrics.svg" width="100%"> |
| 122 | +``` |
0 commit comments