Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/preview-updater.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# $schema: ../resources/schema.json

package:
manager: 'uses:'
name: 'TheDragonCode/github-preview-updater@v2'

image:
parameters:
icon: 'photograph'
packageManager: 'uses:'
packageName: 'TheDragonCode/github-preview-updater@v1'
22 changes: 22 additions & 0 deletions .junie/guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Triggers

### JSON schema

Aliases:
- `update schema`
- `upgrade schema`
- `schema`
- `json schema`

Ignore the following properties:

- `directory`
- `repository.owner`
- `repository.repo`

Steps:

1. Carefully study the `Config` interface in the `src/types/defaults.ts` file.
2. Study its dependencies.
3. Memorize the overall relationship scheme of these interfaces.
4. Update the JSON schema in the `resources/schema.json` file in accordance with the new requirements.
110 changes: 67 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ The action is setting the following outputs:
## Configuration

> [!TIP]
>
>
> Support for working with a global settings file at the organization level (the `.github` repository).
>
>
> For example,
>
> - template is `https://github.com/<repo>/.github/blob/main/<configPath>`.
Expand All @@ -82,47 +82,7 @@ All fields are optional—omitted ones fall back to defaults.
```yaml
# $schema: https://raw.githubusercontent.com/TheDragonCode/github-preview-updater/refs/heads/main/resources/schema.json

path:
readme: README.md # Target file to update

image:
url: https://banners.beyondco.de/{title}.png
parameters:
pattern: topography
style: style_2
fontSize: 100px
icon: code

# Declares the use of the package manager.
# It is a regular string that will be substituted into the URL address.
#
# Reserved words: composer | npm | yarn | auto | none
#
# Any package manager name can be specified.
#
# By default, auto
packageManager: auto

# By default, the package name is taken from the composer.json or package.json file.
packageName: ''

# Add a prefix for global installation (`composer global require`, `npm install -g`)
# The parameter will be ignored when a non-standard package manager name is specified in
# the `packageManager` parameter.
packageGlobal: false

# Add a prefix for dev installation (`composer require --dev`, `npm install --save-dev`)
# The parameter will be ignored when a non-standard package manager name is specified in
# the `packageManager` parameter
packageDev: false

# By default, the repository name will be used.
# For example, for https://github.com/TheDragonCode/github-preview-updater, it will take `preview-updater`
# and convert it to `Preview Updater`.
title: '' # Fallbacks to repo name (Title Case)

# By default, the package description will be used (the ` description ` key in composer.json or package.json).
description: '' # Fallbacks to owner name or package description
path: README.md # Target file to update

repository:
commit:
Expand All @@ -138,12 +98,76 @@ repository:
body: ''
assignees: [ ]
labels: [ 'preview' ]

data:
# By default, the repository name will be used.
# For example, for https://github.com/TheDragonCode/github-preview-updater, it will take `preview-updater`
# and convert it to `Preview Updater`.
title: '' # Fallbacks to repo name (Title Case)

# By default, the package description will be used (the ` description ` key in composer.json or package.json).
description: '' # Fallbacks to owner name or package description

package:
# Declares the use of the package manager.
# It is a regular string that will be substituted into the URL address.
#
# Reserved words: composer | npm | yarn | auto | none
#
# Any package manager name can be specified.
#
# By default, auto
manager: auto

# Add a prefix for global installation (`composer global require`, `npm install -g`)
# The parameter will be ignored when a non-standard package manager name is specified in
# the `packageManager` parameter.
global: false

# Add a prefix for dev installation (`composer require --dev`, `npm install --save-dev`)
# The parameter will be ignored when a non-standard package manager name is specified in
# the `packageManager` parameter
dev: false

# By default, the package name is taken from the composer.json or package.json file.
name: ''

image:
url: https://banners.beyondco.de/{title}.png

# May contain any keys and values
parameters:
pattern: topography
style: style_2
fontSize: 100px
icon: code

```

Currently, the project generates previews through [banners.beyondco.de](https://banners.beyondco.de) and the parameters
are specified for it.
But you can use any other service by replacing the URL.

### Information on how link formation works

An object is created, containing combined data from the [`data`](src/types/data.ts) and [
`image.parameters`](src/types/image.ts) objects.

A link is taken from the `image.url` parameter and using the `replace` method, everything is replaced in it according to
the `{key}` pattern, where `key` is the object key from the merged object.

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

After this, the original `image.parameters` object is taken and query parameters are formed from it.

For example, if the `image.parameters` object is `{ foo: 'asd', bar: 'zxc' }`, then the resulting query parameters
will be `?foo=asd&bar=zxc`.

Ultimately, the image link will look like this:
`https://banners.beyondco.de/Qwe%20rty/asd-zxc.png?foo=asd&bar=zxc`.

## License

This project is licensed under the [MIT License](LICENSE.md).
203 changes: 120 additions & 83 deletions resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,42 @@
"type": "object",
"additionalProperties": false,
"properties": {
"path": {
"type": "object",
"additionalProperties": false,
"properties": {
"readme": {
"type": "string",
"description": "Target README file where the banner will be inserted",
"default": "README.md"
}
}
"readme": {
"type": "string",
"description": "Target README file where the banner will be inserted",
"default": "README.md"
},
"image": {
"repository": {
"type": "object",
"additionalProperties": false,
"properties": {
"url": {
"type": "string",
"description": "Banner generation service URL",
"default": "https://banners.beyondco.de/{title}.png"
},
"parameters": {
"type": "object",
"additionalProperties": false,
"properties": {
"pattern": {
"type": "string",
"default": "topography"
},
"style": {
"type": "string",
"default": "style_2"
},
"fontSize": {
"type": "string",
"default": "100px"
},
"icon": {
"type": "string",
"default": "code"
},
"packageManager": {
"description": "Package manager name. Reserved values: composer | npm | yarn | auto | none",
"anyOf": [
{
"type": "string",
"enum": [
"composer",
"npm",
"yarn",
"auto",
"none"
]
},
{
"type": "string"
}
],
"default": "auto"
},
"packageName": {
"type": "string",
"description": "Package name. By default taken from composer.json or package.json"
},
"packageGlobal": {
"type": "boolean",
"description": "Add prefix for global installation",
"default": false
},
"packageDev": {
"type": "boolean",
"description": "Add a prefix for dev installation",
"default": false
},
"title": {
"type": "string",
"description": "Banner title. The repository name is used by default"
},
"description": {
"type": "string",
"description": "Package description. The repository description is used by default"
}
"default": {
"commit": {
"branch": "preview/banner-{random}",
"title": "docs(preview): Update preview",
"author": {
"name": "github-actions",
"email": "github-actions@github.com"
}
},
"pullRequest": {
"title": "Update preview",
"labels": [
"preview"
]
}
}
},
"repository": {
"type": "object",
"additionalProperties": false,
},
"properties": {
"commit": {
"type": "object",
"additionalProperties": false,
"default": {
"branch": "preview/banner-{random}",
"title": "docs(preview): Update preview",
"author": {
"name": "github-actions",
"email": "github-actions@github.com"
}
},
"properties": {
"branch": {
"type": "string",
Expand Down Expand Up @@ -163,6 +107,99 @@
}
}
}
},
"data": {
"type": "object",
"additionalProperties": false,
"properties": {
"title": {
"type": "string",
"description": "Banner title. Defaults to repository name"
},
"description": {
"type": "string",
"description": "Banner description. Defaults to repository description or owner"
}
}
},
"package": {
"type": "object",
"additionalProperties": false,
"default": {
"manager": "auto",
"global": false,
"dev": false
},
"properties": {
"manager": {
"description": "Package manager name. Reserved values: composer | npm | yarn | auto | none",
"anyOf": [
{
"type": "string",
"enum": [
"composer",
"npm",
"yarn",
"auto",
"none"
]
},
{
"type": "string"
}
],
"default": "auto"
},
"global": {
"type": "boolean",
"description": "Add prefix for global installation",
"default": false
},
"dev": {
"type": "boolean",
"description": "Add a prefix for dev installation",
"default": false
},
"name": {
"type": "string",
"description": "Package name. By default taken from composer.json or package.json"
}
}
},
"image": {
"type": "object",
"additionalProperties": false,
"default": {
"url": "https://banners.beyondco.de/{title}.png",
"parameters": {
"pattern": "topography",
"style": "style_2",
"fontSize": "100px",
"md": "1",
"showWatermark": "1"
}
},
"properties": {
"url": {
"type": "string",
"description": "Banner generation service URL",
"default": "https://banners.beyondco.de/{title}.png"
},
"parameters": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Query parameters passed to the image service",
"default": {
"pattern": "topography",
"style": "style_2",
"fontSize": "100px",
"md": "1",
"showWatermark": "1"
}
}
}
}
}
}
Loading