Skip to content

Commit c35f52f

Browse files
Merge pull request #142 from TheDragonCode/copilot/refactor-readme-file
docs: refactor README structure and improve examples
2 parents feb1c0d + 7b858d2 commit c35f52f

1 file changed

Lines changed: 36 additions & 39 deletions

File tree

README.md

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
<img src="https://banners.beyondco.de/GitHub%20Preview%20Updater.png?pattern=topography&style=style_2&fontSize=100px&md=1&showWatermark=1&icon=photograph&theme=light&packageManager=uses%3A&packageName=TheDragonCode%2Fgithub-preview-updater%40v2&description=Lightweight+preview+update+in+your+repository&images=photograph" alt="GitHub Preview Updater">
66
</picture>
77

8-
Both a light-theme and a dark-theme variant of the banner are generated automatically.
8+
Both light and dark banner variants are generated automatically.
99

10-
### How it works
10+
## How it works
1111

12-
1. The action reads your `composer.json` / `package.json` to detect the package manager, package name, and description.
13-
2. It builds the banner URL for [banners.beyondco.de](https://banners.beyondco.de) using the collected data.
14-
3. It replaces the `<picture>` block in your `README.md` with the freshly generated URLs.
12+
1. The action reads `composer.json` / `package.json` to detect the package manager, package name, and description.
13+
2. It builds the banner URL for [banners.beyondco.de](https://banners.beyondco.de) from the collected data.
14+
3. It replaces the `<picture>` block in `README.md` with refreshed URLs.
1515
4. If the file changed, it commits the update to a new branch and opens a pull request.
1616

17-
## Quick start
17+
## Quick start (reusable workflow)
1818

19-
Create the file `.github/workflows/preview.yml` with the following content:
19+
Create `.github/workflows/preview.yml`:
2020

2121
```yaml
2222
name: Preview Updater
@@ -35,18 +35,18 @@ jobs:
3535
uses: TheDragonCode/.github/.github/workflows/preview.yml@main
3636
```
3737
38-
You can see a workflow here: https://github.com/TheDragonCode/.github/blob/main/.github/workflows/preview.yml
38+
Example reusable workflow: https://github.com/TheDragonCode/.github/blob/main/.github/workflows/preview.yml
3939
40-
## Usage
40+
## Standalone usage (direct action call)
4141
42-
Create the file `.github/workflows/preview.yml` with the following content:
42+
If you prefer not to use the reusable workflow, create `.github/workflows/preview.yml` like this:
4343

4444
```yaml
4545
name: Preview Updater
4646
4747
on:
4848
schedule:
49-
- cron: '20 2 * * *' # 02:20 AM on everyday
49+
- cron: '20 2 * * *' # 02:20 AM every day
5050
workflow_dispatch:
5151
5252
permissions:
@@ -97,27 +97,27 @@ jobs:
9797
run: gh pr merge --merge --delete-branch ${{ steps.preview.outputs.pullRequestNumber }}
9898
```
9999

100-
The action is setting the following outputs:
100+
The action exposes these outputs:
101101

102-
| Name | Description |
103-
|---------------------|---------------------------------------------------------------------------------------|
104-
| `branchName` | The name of the git branch created for the purpose of updating the readme file. |
105-
| `pullRequestNumber` | The number of the GitHub pull request created for the purpose of updating the readme. |
106-
| `pullRequestUrl` | The URL of the GitHub pull request created for the purpose of updating the readme. |
102+
| Name | Description |
103+
|---------------------|------------------------------------------------------|
104+
| `branchName` | Name of the branch created for README update. |
105+
| `pullRequestNumber` | Number of the created pull request. |
106+
| `pullRequestUrl` | URL of the created pull request. |
107107

108108
## Configuration
109109

110110
> [!TIP]
111111
>
112-
> Support for working with a global settings file at the organization level (the `.github` repository).
112+
> You can keep a shared config in the organization-level `.github` repository.
113113
>
114-
> For example,
114+
> Example:
115115
>
116-
> - template is `https://github.com/<repo>/.github/blob/main/<config>`.
117-
> - result is `https://github.com/TheDragonCode/.github/blob/main/.github/preview-updater.yml`.
116+
> - Template: `https://github.com/<repo>/.github/blob/main/<config>`
117+
> - Result: `https://github.com/TheDragonCode/.github/blob/main/.github/preview-updater.yml`
118118

119-
Create `.github/preview-updater.yml` (or provide your own path via `config`).
120-
All fields are optionalomitted ones fall back to defaults.
119+
Create `.github/preview-updater.yml` (or set your own path via `config`).
120+
All fields are optional; omitted values fallback to defaults.
121121

122122
```yaml
123123
# $schema: https://raw.githubusercontent.com/TheDragonCode/github-preview-updater/refs/heads/main/resources/schema.json
@@ -181,28 +181,25 @@ repository:
181181
labels: [ 'preview' ]
182182
```
183183
184-
Currently, the project generates previews through [banners.beyondco.de](https://banners.beyondco.de) and the parameters
185-
are specified for it.
186-
But you can use any other service by replacing the URL.
184+
By default, previews are generated with [banners.beyondco.de](https://banners.beyondco.de).
185+
You can use any service by replacing `image.url`.
187186

188-
### Information on how link formation works
187+
### How URL generation works
189188

190-
An object is created, containing combined data from the [`data`](src/types/data.ts) and [
191-
`image.parameters`](src/types/image.ts) objects.
189+
A merged object is built from [`data`](src/types/data.ts) and [`image.parameters`](src/types/image.ts).
192190

193-
A link is taken from the `image.url` parameter and using the `replace` method, everything is replaced in it according to
194-
the `{key}` pattern, where `key` is the object key from the merged object.
191+
Then values are substituted into `image.url` by `{key}` placeholders.
195192

196-
For example, if the `image.url` parameter is `https://banners.beyondco.de/{title}/{foo}-{bar}.png`, and the `data`
197-
object is `{ title: 'Qwe rty', foo: 'asd', bar: 'zxc' }`, then the resulting link will be
193+
For example, if `image.url` is `https://banners.beyondco.de/{title}/{foo}-{bar}.png`, and `data` is
194+
`{ title: 'Qwe rty', foo: 'asd', bar: 'zxc' }`, the resulting link is:
198195
`https://banners.beyondco.de/Qwe%20rty/asd-zxc.png`.
199196

200-
After this, the original `image.parameters` object is taken and query parameters are formed from it.
197+
After that, query params are built from `image.parameters`.
201198

202-
For example, if the `image.parameters` object is `{ foo: 'asd', bar: 'zxc' }`, then the resulting query parameters
203-
will be `?foo=asd&bar=zxc`.
199+
For example, for `{ foo: 'asd', bar: 'zxc' }`, the query string is:
200+
`?foo=asd&bar=zxc`.
204201

205-
Ultimately, the image link will look like this:
202+
Final image URL example:
206203
`https://banners.beyondco.de/Qwe%20rty/asd-zxc.png?foo=asd&bar=zxc`.
207204

208205
## Recipes
@@ -243,7 +240,7 @@ jobs:
243240
if: steps.preview1.outputs.pullRequestNumber != ''
244241
env:
245242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
246-
run: gh pr merge --merge --delete-branch ${{ steps.preview.outputs.pullRequestNumber }}
243+
run: gh pr merge --merge --delete-branch ${{ steps.preview1.outputs.pullRequestNumber }}
247244
248245
bar:
249246
runs-on: ubuntu-latest
@@ -265,7 +262,7 @@ jobs:
265262
if: steps.preview2.outputs.pullRequestNumber != ''
266263
env:
267264
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
268-
run: gh pr merge --merge --delete-branch ${{ steps.preview.outputs.pullRequestNumber }}
265+
run: gh pr merge --merge --delete-branch ${{ steps.preview2.outputs.pullRequestNumber }}
269266
```
270267

271268
## FAQ

0 commit comments

Comments
 (0)