Skip to content

Commit daf6670

Browse files
committed
docs: update action setup
1 parent 5baaf7b commit daf6670

File tree

1 file changed

+61
-54
lines changed
  • .github/readme/partials/documentation/setup

1 file changed

+61
-54
lines changed

.github/readme/partials/documentation/setup/action.md

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,114 +2,121 @@
22

33
Setup a GitHub Action which runs periodically and pushes generated images to a repository.
44

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
66

7-
```markdown
8-
<!-- If you're using "master" as default branch -->
9-
![Metrics](https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg)
10-
<!-- If you're using "main" as default branch -->
11-
![Metrics](https://github.com/my-github-user/my-github-user/blob/main/github-metrics.svg)
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).
198

209
![Setup personal repository](/.github/readme/imgs/setup_personal_repository.png)
2110

2211
Its `README.md` will be displayed on your user profile:
2312

2413
![GitHub Profile Example](/.github/readme/imgs/example_github_profile.png)
2514

26-
### 1. Create a GitHub personal token
15+
## 1️ Create a GitHub personal token
2716

2817
From the `Developer settings` of your account settings, select `Personal access tokens` to create a new token.
2918

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)
3529
3630
![Setup a GitHub personal token](/.github/readme/imgs/setup_personal_token.png)
3731

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:
3933

4034
![Enable "Include private contributions on my profile`"](/.github/readme/imgs/setup_private_contributions.png)
4135

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:
4337

4438
![Plugin error example](https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.error.svg)
4539

46-
### 2. Put your GitHub personal token in your repository secrets
40+
## 2️ Put your GitHub personal token in repository secrets
4741

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.
4943

5044
![Setup a repository secret](/.github/readme/imgs/setup_repository_secret.png)
5145

52-
### 3. Create a GitHub Action workflow in your repository
46+
## 3️ Setup GitHub Action workflow
5347

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:
5549

5650
```yaml
5751
name: Metrics
5852
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
6256
workflow_dispatch:
57+
# (optional) Run workflow when pushing on master/main
6358
push: {branches: ["master", "main"]}
6459
jobs:
6560
github-metrics:
6661
runs-on: ubuntu-latest
6762
steps:
68-
# See action.yml for all options
6963
- uses: lowlighter/metrics@latest
7064
with:
71-
# Your GitHub token
7265
token: ${{ secrets.METRICS_TOKEN }}
7366
```
7467
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.
7869
7970
![Action update example](/.github/readme/imgs/example_action_update.png)
8071
81-
#### Choosing between `@latest`, `@master` or a fork
72+
### 3️.1️ Choosing between `@latest`, `@master`/`@main`, a fork or a pinned version
8273

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:
8575

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+
-
8788

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*
8992
```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
9294
```
9395

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!
9597

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*
9799

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.
99102

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.
101104

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`
103106

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).
105108

106-
Update your README.md to embed your metrics:
109+
*Example: add rendered image with markdown*
110+
```markdown
111+
![Metrics](/github-metrics.svg)
112+
```
107113

114+
*Example: add rendered image with html for more customization*
108115
```markdown
109-
<!-- If you're using "master" as default branch -->
110-
![Metrics](https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg)
111-
<!-- If you're using "main" as default branch -->
112-
![Metrics](https://github.com/my-github-user/my-github-user/blob/main/github-metrics.svg)
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

Comments
 (0)